diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/libkern/arc4random.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/libkern/arc4random.c b/sys/libkern/arc4random.c index b6d9070..4eefb69 100644 --- a/sys/libkern/arc4random.c +++ b/sys/libkern/arc4random.c @@ -41,8 +41,12 @@ arc4_randomstir (void) int r, n; r = read_random(key, sizeof(key)); - for (n = r; n < sizeof(key); n++) - key[n] = key[n % r]; + /* if r == 0 || -1, just use what was on the stack */ + if (r > 0) + { + for (n = r; n < sizeof(key); n++) + key[n] = key[n % r]; + } for (n = 0; n < 256; n++) { |