Fixed an evil bug where rawname() could write across the boundaries of

an array. The bug became obvious in the old system where the array was only
32 characters long (now MAXPATHLEN). Dump honored its name then (:-)
and dumped its core when calling dump -w for a fstab that contained rather long
NFS file system names. Even though this is rather unlikely to happen now,
a bug is a bug:)
This commit is contained in:
Joerg Wunsch 1994-10-28 17:26:27 +00:00
parent 3023486ce7
commit 56d5f6db85

View File

@ -537,10 +537,10 @@ rawname(cp)
if (dp == NULL)
return (NULL);
*dp = '\0';
(void)strcpy(rawbuf, cp);
(void)strncpy(rawbuf, cp, MAXPATHLEN - 1);
*dp = '/';
(void)strcat(rawbuf, "/r");
(void)strcat(rawbuf, dp + 1);
(void)strncat(rawbuf, "/r", strlen(rawbuf) - (MAXPATHLEN - 1));
(void)strncat(rawbuf, dp + 1, strlen(rawbuf) - (MAXPATHLEN - 1));
return (rawbuf);
}