Use safe strlcpy rather than unsafe strncpy. After marcel's last fix,

there was still one overflow possible.  strlcpy is faster anyway
because it doesn't unexpectedly zero the entire length of the string
when copying short strings....
This commit is contained in:
Warner Losh 2006-08-05 18:22:11 +00:00
parent a323dd4352
commit 2fdfd0fee2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=161004

View File

@ -226,8 +226,7 @@ read_kld(char *filename, char *kldname)
cp = strrchr(kldname, '.');
nmlen = cp ? min(MAXMODNAME, cp - kldname) :
min(MAXMODNAME, strlen(kldname));
strncpy(kldmodname, kldname, nmlen);
kldmodname[nmlen] = '\0';
strlcpy(kldmodname, kldname, nmlen);
/* fprintf(fxref, "%s:%s:%d\n", kldmodname, kldname, 0);*/
}
do {
@ -259,8 +258,7 @@ maketempfile(char *dest, const char *root)
char *p;
int fd;
strncpy(dest, root, MAXPATHLEN - 1);
dest[MAXPATHLEN-1] = '\0';
strlcpy(dest, root, MAXPATHLEN);
if ((p = strrchr(dest, '/')) != 0)
p++;