NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/48531: rnd_getmore bit/byte confusion



>Number:         48531
>Category:       kern
>Synopsis:       rnd_getmore bit/byte confusion
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 17 14:45:00 +0000 2014
>Originator:     pooka%iki.fi@localhost
>Release:        
>Organization:
>Environment:
>Description:
rnd_getmore(RND_POOLBITS - entropy_count * 8);

So that's [bits - 8*bits], and rnd_getmore() seems to want bytes.

>How-To-Repeat:

>Fix:
Guessing this was intended, but I'm having trouble keeping track of bits/bytes 
in that code, so someone who understands the code please check:

Index: kern_rndq.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_rndq.c,v
retrieving revision 1.21
diff -u -r1.21 kern_rndq.c
--- kern_rndq.c 29 Aug 2013 01:04:49 -0000      1.21
+++ kern_rndq.c 17 Jan 2014 14:33:30 -0000
@@ -1033,7 +1033,7 @@
 #endif
        entropy_count = rndpool_get_entropy_count(&rnd_pool);
        if (entropy_count < (RND_ENTROPY_THRESHOLD * 2 + len) * 8) {
-               rnd_getmore(RND_POOLBITS - entropy_count * 8);
+               rnd_getmore((RND_POOLBITS - entropy_count) / 8);
        }
        return rndpool_extract_data(&rnd_pool, p, len, flags);
 }



Home | Main Index | Thread Index | Old Index