1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-02-01 17:00:36 +00:00

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

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

Reported by:	Coverity
CID:		1009980
MFC after:	1 week
This commit is contained in:
Don Lewis 2016-05-13 00:02:03 +00:00
parent 52af39633a
commit 3b7e0c53d5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=299579

View File

@ -390,7 +390,7 @@ getprivs(long id, int quotatype, char *fspath)
if ((qup = (struct quotause *)calloc(1, sizeof(*qup))) == NULL)
errx(2, "out of memory");
qup->qf = qf;
strncpy(qup->fsname, fs->fs_file, sizeof(qup->fsname));
strlcpy(qup->fsname, fs->fs_file, sizeof(qup->fsname));
if (quota_read(qf, &qup->dqblk, id) == -1) {
warn("cannot read quotas on %s", fs->fs_file);
freeprivs(qup);