1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-29 17:31:02 +01:00

42518, CVE-2018-1071: check bounds when copying path in hashcmd()

This commit is contained in:
Oliver Kiddle 2018-03-24 15:02:41 +01:00
parent beadc29214
commit 679b71ec4d
3 changed files with 9 additions and 4 deletions

View file

@ -2283,10 +2283,10 @@ struncpy(char **s, char *t, int n)
{
char *u = *s;
while (n--)
*u++ = *t++;
while (n-- && (*u++ = *t++));
*s = u;
*u = '\0';
if (n > 0) /* just one null-byte will do, unlike strncpy(3) */
*u = '\0';
}
/* Return the number of elements in an array of pointers. *