bin/80411: bin/df/df.c sign errors in calls to getbsize

Steve Ames steve at virtual-voodoo.com
Wed Apr 27 09:40:11 PDT 2005


>Number:         80411
>Category:       bin
>Synopsis:       bin/df/df.c sign errors in calls to getbsize
>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:   Wed Apr 27 16:40:10 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Steve Ames
>Release:        FreeBSD 6.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD basement.virtual-voodoo.com 6.0-CURRENT FreeBSD 6.0-CURRENT #48: Sun Apr 24 13:04:02 EST 2005 steve at basement.virtual-voodoo.com:/usr/obj/usr/src/sys/SB i386


>Description:
	in bin/df/df.c calls are made getbsize(3) using a variable of
        type u_long when the prototype specifically requests long:

        char *getbsize(int *headerlenp, long *blocksizep);

        The solution is to fix the calls to send signed long instead of
        u_long. I'm fairly sure that a negative value will never be 
        placed in blocksizep so u_long seems to be appropriate but until
        (and unless) the prototype and library are changed to unsigned
        then calls to getbsize should use signed variables to avoid
        confusion. This becomes more true with gcc4.0 and higher where
        sign warnings are flagged a little heavier.


>How-To-Repeat:
	Not Applicable

>Fix:

--- df.c.old    Wed Apr 27 11:28:11 2005
+++ df.c        Wed Apr 27 11:29:32 2005
@@ -372,7 +372,7 @@
static void
prtstat(struct statfs *sfsp, struct maxwidths *mwp)
{
-       static u_long blocksize;
+       static long blocksize;
       static int headerlen, timesthrough = 0;
       static const char *header;
       int64_t used, availblks, inodes;
@@ -449,7 +449,7 @@
static void
update_maxwidths(struct maxwidths *mwp, const struct statfs *sfsp)
{
-       static u_long blocksize = 0;
+       static long blocksize = 0;
       int dummy;

       if (blocksize == 0)



>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list