Subject: bin/14584: rndctl -s prints stats as signed rather than unsigned
To: None <gnats-bugs@gnats.netbsd.org>
From: Dave Huang <khym@azeotrope.org>
List: netbsd-bugs
Date: 11/14/2001 03:38:37
>Number:         14584
>Category:       bin
>Synopsis:       rndctl -s prints stats as signed rather than unsigned
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 14 01:39:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Dave Huang
>Release:        NetBSD 1.5Y
>Organization:
Name: Dave Huang         |  Mammal, mammal / their names are called /
INet: khym@azeotrope.org |  they raise a paw / the bat, the cat /
FurryMUCK: Dahan         |  dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 26 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++
>Environment:
	
	
System: NetBSD yerfable.azeotrope.org 1.5Y NetBSD 1.5Y (YERFABLE) #182: Sat Nov 3 03:42:35 CST 2001 khym@yerfable.azeotrope.org:/usr/src.local/sys/arch/alpha/compile/YERFABLE alpha
Architecture: alpha
Machine: alpha
>Description:
	rndctl -s prints its statistics using the %d printf format,
rather than %u, even though the members of rndpoolstat_t are all
unsigned. Which causes problems if a counter ever goes past 2^31-1:

          4293702 bits mixed into pool
             1728 bits currently stored in pool (max 4096)
          2708864 bits of entropy discarded due to full pool
          1583110 hard-random bits generated
        -1496739174 pseudo-random bits generated
>How-To-Repeat:
	Read a couple billion bits from /dev/urandom, then rndctl -s
>Fix:
--- /usr/src/sbin/rndctl/rndctl.c	Fri Sep 14 17:58:08 2001
+++ rndctl.c	Wed Nov 14 03:33:17 2001
@@ -223,13 +223,13 @@
 	if (ioctl(fd, RNDGETPOOLSTAT, &rs) < 0)
 		err(1, "ioctl(RNDGETPOOLSTAT)");
 
-	printf("\t%9d bits mixed into pool\n", rs.added);
-	printf("\t%9d bits currently stored in pool (max %d)\n",
+	printf("\t%9u bits mixed into pool\n", rs.added);
+	printf("\t%9u bits currently stored in pool (max %d)\n",
 	    rs.curentropy, rs.maxentropy);
-	printf("\t%9d bits of entropy discarded due to full pool\n",
+	printf("\t%9u bits of entropy discarded due to full pool\n",
 	    rs.discarded);
-	printf("\t%9d hard-random bits generated\n", rs.removed);
-	printf("\t%9d pseudo-random bits generated\n", rs.generated);
+	printf("\t%9u hard-random bits generated\n", rs.removed);
+	printf("\t%9u pseudo-random bits generated\n", rs.generated);
 
 	close(fd);
 }

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