summaryrefslogtreecommitdiffstats
path: root/Src/string.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2017-05-11 17:33:30 +0100
committerPeter Stephenson <pws@zsh.org>2017-05-11 17:33:30 +0100
commit4bb81eefbd2a0093d0d3c1b9f4aa1de027512834 (patch)
tree190fec71e8b0c6de362bfbe433ba8619eaef242b /Src/string.c
parentunposted: Adding comments to test changed line number in output (diff)
downloadzsh-4bb81eefbd2a0093d0d3c1b9f4aa1de027512834.tar
zsh-4bb81eefbd2a0093d0d3c1b9f4aa1de027512834.tar.gz
zsh-4bb81eefbd2a0093d0d3c1b9f4aa1de027512834.tar.bz2
zsh-4bb81eefbd2a0093d0d3c1b9f4aa1de027512834.tar.lz
zsh-4bb81eefbd2a0093d0d3c1b9f4aa1de027512834.tar.xz
zsh-4bb81eefbd2a0093d0d3c1b9f4aa1de027512834.tar.zst
zsh-4bb81eefbd2a0093d0d3c1b9f4aa1de027512834.zip
41096: Don't assume null termination copying string.
At this point the string may contain embedded nulls or not have a null termination at all. Also, as we always have the length memcpy() is more efficient.
Diffstat (limited to 'Src/string.c')
-rw-r--r--Src/string.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Src/string.c b/Src/string.c
index a8da14fe0..9e14ef949 100644
--- a/Src/string.c
+++ b/Src/string.c
@@ -52,7 +52,8 @@ dupstring_wlen(const char *s, unsigned len)
if (!s)
return NULL;
t = (char *) zhalloc(len + 1);
- strcpy(t, s);
+ memcpy(t, s, len);
+ t[len] = '\0';
return t;
}