Module Name:    src
Committed By:   dholland
Date:           Mon Jan 30 06:02:12 UTC 2012

Modified Files:
        src/usr.bin/quota: quotautil.c

Log Message:
Don't strlcpy from a string buffer to itself; the behavior is not
defined.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/quota/quotautil.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/quota/quotautil.c
diff -u src/usr.bin/quota/quotautil.c:1.4 src/usr.bin/quota/quotautil.c:1.5
--- src/usr.bin/quota/quotautil.c:1.4	Wed Jan 25 01:24:07 2012
+++ src/usr.bin/quota/quotautil.c	Mon Jan 30 06:02:12 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quotautil.c,v 1.4 2012/01/25 01:24:07 dholland Exp $ */
+/*	$NetBSD: quotautil.c,v 1.5 2012/01/30 06:02:12 dholland Exp $ */
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)quota.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: quotautil.c,v 1.4 2012/01/25 01:24:07 dholland Exp $");
+__RCSID("$NetBSD: quotautil.c,v 1.5 2012/01/30 06:02:12 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -76,6 +76,7 @@ hasquota(char *buf, size_t len, struct f
 	char *opt;
 	char *cp = NULL;
 	static char initname, usrname[100], grpname[100];
+	char optbuf[256];
 
 	if (!initname) {
 		(void)snprintf(usrname, sizeof(usrname), "%s%s",
@@ -84,8 +85,8 @@ hasquota(char *buf, size_t len, struct f
 		    qfextension[GRPQUOTA], qfname);
 		initname = 1;
 	}
-	strlcpy(buf, fs->fs_mntops, len);
-	for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) {
+	strlcpy(optbuf, fs->fs_mntops, sizeof(optbuf));
+	for (opt = strtok(optbuf, ","); opt; opt = strtok(NULL, ",")) {
 		if ((cp = strchr(opt, '=')) != NULL)
 			*cp++ = '\0';
 		if (type == USRQUOTA && strcmp(opt, usrname) == 0)

Reply via email to