From f15cc9e98f102b443a7b1bc97ce7b524d3453c7e Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Sun, 13 Apr 2008 00:22:18 +0000 Subject: Use arc4random_buf() when requesting more than a single word of output Use arc4random_uniform() when the desired random number upper bound is not a power of two ok deraadt@ millert@ --- lib/libc/stdlib/malloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index 8348b7ede18..c4869527adb 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.88 2008/02/20 18:31:34 otto Exp $ */ +/* $OpenBSD: malloc.c,v 1.89 2008/04/13 00:22:16 djm Exp $ */ /* * ---------------------------------------------------------------------------- @@ -1140,7 +1140,7 @@ malloc_bytes(size_t size) if (malloc_guard) { /* Walk to a random position. */ - i = arc4random() % bp->free; + i = arc4random_uniform(bp->free); while (i > 0) { u += u; k++; -- cgit v1.2.3