Use strlcpy() instead of strncpy() to ensure that qf->fsname is NUL

terminated.  Don't bother checking for truncation since the subsequent
stat() call should detect that and fail.

Reported by:	Coverity
CID:		1018189
MFC after:	1 week
This commit is contained in:
truckman 2016-05-13 00:26:14 +00:00
parent 4e9e03d38e
commit 61eb4d5d8a

View File

@ -124,7 +124,7 @@ quota_open(struct fstab *fs, int quotatype, int openflags)
return (NULL);
qf->fd = -1;
qf->quotatype = quotatype;
strncpy(qf->fsname, fs->fs_file, sizeof(qf->fsname));
strlcpy(qf->fsname, fs->fs_file, sizeof(qf->fsname));
if (stat(qf->fsname, &st) != 0)
goto error;
qf->dev = st.st_dev;