1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-09-28 15:01:21 +02:00

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.
This commit is contained in:
Peter Stephenson 2017-05-11 17:33:30 +01:00
parent 1caaa933b4
commit 4bb81eefbd
2 changed files with 7 additions and 1 deletions

@ -1,3 +1,8 @@
2017-05-11 Peter Stephenson <p.stephenson@samsung.com>
* 41096: Src/string.c: Fix dupstring_wlen() for unmetafied
string. It's not safe to assume null termination.
2017-05-09 Peter Stephenson <p.w.stephenson@ntlworld.com>
* unposted: Test/D02glob.ztst: Adding comment to test changed

@ -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;
}