Subject: random()
To: None <tech-security@netbsd.org>
From: Jun-ichiro itojun Hagino <itojun@itojun.org>
List: tech-security
Date: 09/06/2003 07:48:15
perry:
> Then perhaps we should remove random(9) before it causes more trouble,
> or at least disable building it for now.

	if there's no special reason for using random(9), could you please
	replace them with arc4random()? (mask it with INT32_MAX if you don't
	want the top bit set)

	or we could do following in sys/lib/libkern/random.c:

u_long
random()
{
	return arc4random() & INT32_MAX;
}

itojun



itojun[starfruit:~/NetBSD/src/sys] find . -name \*.c -print | xargs grep 'random(' | grep -v arc4
./arch/acorn26/iobus/ioc.c:             r = random() & (statvar - 1);
./arch/atari/dev/clock.c:               r = random() & var;
./arch/arm/footbridge/footbridge_clock.c:               r = random() & (statvar-1);
./arch/hp300/hp300/clock.c:             r = random() & (var - 1);
./arch/hpcmips/tx/tx39.c:               magic0 = random();
./arch/hpcmips/tx/tx39.c:               magic1 = random();
./arch/hpcmips/vr/vr.c:         x = random();
./arch/hpcmips/vr/vr.c:         x = random();
./arch/hpcsh/hpcsh/machdep.c:   x = random();
./arch/hpcsh/hpcsh/machdep.c:           x = random();
./arch/hpcsh/hpcsh/machdep.c:           x = random();
./arch/hpcsh/dev/hd64461/hd64461video.c:        x = random();
./arch/sparc64/sparc64/clock.c:         r = random() & (var - 1);
./arch/evbarm/ifpga/ifpga_clock.c:              r = random() & (var - 1);
./arch/sh5/sh5/sh5_clock.c:             r = random() & (clock_statvar - 1);
./netiso/clnp_frag.c:                                   num_bytes *= troll_random();
./netiso/clnp_frag.c:troll_random()
./netisdn/i4b_l4mgmt.c:         val = (u_char)random();
./netisdn/i4b_tei.c:    val = (u_short)random();