MFC r316611:

sbin/mount: strcpy -> strlcpy

Reported by:	Coverity
CID:		1011173, 1011174
Sponsored by:	Spectra Logic Corp
This commit is contained in:
Alan Somers 2017-05-30 22:36:24 +00:00
parent e74e688480
commit 20e7868288
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/stable/10/; revision=319261

View File

@ -597,7 +597,7 @@ mountfs(const char *vfstype, const char *spec, const char *name, int flags,
append_arg(&mnt_argv, execname); append_arg(&mnt_argv, execname);
mangle(optbuf, &mnt_argv); mangle(optbuf, &mnt_argv);
if (mountprog != NULL) if (mountprog != NULL)
strcpy(execname, mountprog); strlcpy(execname, mountprog, sizeof(execname));
append_arg(&mnt_argv, strdup(spec)); append_arg(&mnt_argv, strdup(spec));
append_arg(&mnt_argv, strdup(name)); append_arg(&mnt_argv, strdup(name));
@ -905,8 +905,9 @@ putfsent(struct statfs *ent)
if (strncmp(ent->f_mntfromname, "<below>", 7) == 0 || if (strncmp(ent->f_mntfromname, "<below>", 7) == 0 ||
strncmp(ent->f_mntfromname, "<above>", 7) == 0) { strncmp(ent->f_mntfromname, "<above>", 7) == 0) {
strcpy(ent->f_mntfromname, (strnstr(ent->f_mntfromname, ":", 8) strlcpy(ent->f_mntfromname,
+1)); (strnstr(ent->f_mntfromname, ":", 8) +1),
sizeof(ent->f_mntfromname));
} }
l = strlen(ent->f_mntfromname); l = strlen(ent->f_mntfromname);