bin/75259: [PATCH] repquota(8) field size a smidge too small

Matthew D.Fuller fullermd at over-yonder.net
Sun Dec 19 08:30:29 PST 2004


>Number:         75259
>Category:       bin
>Synopsis:       [PATCH] repquota(8) field size a smidge too small
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Dec 19 16:30:27 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Matthew D. Fuller
>Release:        FreeBSD 5.3-STABLE i386
>Organization:
>Environment:
System: FreeBSD mortis.sighup.org 5.3-STABLE FreeBSD 5.3-STABLE #0: Sat Nov 20 10:24:06 CST 2004 fullermd at mortis:/usr/obj/usr/src/sys/MORTIS i386


	
>Description:
    repquota(8) lists out the quota information for all users on the
    system.  The first field, naturally, contains the username.  It's
    awful convenient and tempting to pipe the output to sort(1) or the
    like.

    However, that will break all over you if there's a username that's up
    at the max size (16).
>How-To-Repeat:
    Add a user with a 16-char username, put in a bunch of files, then do
    a repquota | sort -n +2 and see if they're near the bottom.

>Fix:

Index: repquota.c
===================================================================
RCS file: /usr/cvs/src/usr.sbin/repquota/repquota.c,v
retrieving revision 1.18
diff -u -r1.18 repquota.c
--- repquota.c	7 Aug 2004 04:28:54 -0000	1.18
+++ repquota.c	19 Dec 2004 16:14:48 -0000
@@ -229,9 +229,9 @@
 	}
 	fclose(qf);
 	printf("%*s                Block  limits                    File  limits\n",
-		max(UT_NAMESIZE,10), " ");
+		max(UT_NAMESIZE+1,10), " ");
 	printf("User%*s   used     soft     hard  grace     used    soft    hard  grace\n",
-		max(UT_NAMESIZE,10), " ");
+		max(UT_NAMESIZE+1,10), " ");
 	for (id = 0; id <= highid[type]; id++) {
 		fup = lookup(id, type);
 		if (fup == 0)
@@ -239,7 +239,7 @@
 		if (fup->fu_dqblk.dqb_curinodes == 0 &&
 		    fup->fu_dqblk.dqb_curblocks == 0)
 			continue;
-		printf("%-*s", max(UT_NAMESIZE,10), fup->fu_name);
+		printf("%-*s", max(UT_NAMESIZE+1,10), fup->fu_name);
 		printf("%c%c %8lu %8lu %8lu %6s",
 			fup->fu_dqblk.dqb_bsoftlimit &&
 			    fup->fu_dqblk.dqb_curblocks >=
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list