Subject: bin/17734: Bug in rndctl command
To: None <>
From: None <>
List: netbsd-bugs
Date: 07/26/2002 16:23:06
>Number:         17734
>Category:       bin
>Synopsis:       Cannot specify a device to rndctl with -t command
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 26 16:24:00 PDT 2002
>Originator:     Bill Dorsey
>Release:        NetBSD 1.5.3 (and earlier releases including 1.5.2)
System: NetBSD 1.5.3 NetBSD 1.5.3 (LILA) #0: Wed Jul 24 15:04:12 PDT 2002 sparc
Architecture: sparc, alpha
Machine: sparc
Rndctl uses several flag variables which get set depending on which
arguments a user passes to the program.  Around line 240 of rndctl.c,
the flags lflag, mflag, and sflag are declared.  A few lines later,
lflag and mflag are initialized to zero, but sflag is NOT initialized
to zero.  If rndctl is called with the arguments "-ce -t net", the
mflag is set.  Then, around line 306, the follownig code appears:

        if ((lflag != 0 || sflag != 0) && mflag != 0)

This code _should_ be skipped (because both lflag and sflag should
be zero when rndctl is called with the argumetns specified above).
However, on two platforms I've tested on (sparc, alpha), the sflag
variable contains garbage because it is an UNINITIALIZED AUTOMATIC
VARIABLE.  As a result, the usage information is printed and
rndctl exits with an error.

This prevents users from addition additional sources of entropy
to the random number generator.  As a result, true random numbers
are generated more slowly which adversely affects programs that
require them like ssh, ssl, etc.

lila# rndctl -ce -t net
usage: rndctl -CEce [-t devtype] [-d devname]
       rndctl -l [-t devtype] [-d devname]


Add a line below where lflag and mflag are initialized to zero (around
line 250) to initialize sflag to zero as well.  Here are the diffs:

Index: rndctl.c
RCS file: /cvsroot/basesrc/sbin/rndctl/rndctl.c,v
retrieving revision 1.6
diff -r1.6 rndctl.c
< /*    $NetBSD: rndctl.c,v 1.5 1999/03/30 17:32:44 mycroft Exp $       */
> /*    $NetBSD: rndctl.c,v 1.6 2000/06/20 02:40:10 sommerfeld Exp $    */
>       sflag = 0;