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:
parent
a323dd4352
commit
2fdfd0fee2
@ -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++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user