summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2007-02-12 20:00:15 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2007-02-12 20:00:15 +0000
commit42a6d0f7134a8f401ecca26ea1b09f8a5650c442 (patch)
treee1befc88951f08402a9d745f0f71b090fb8fce85
parent719ff72de946f76b51c5927ac6243593071819c9 (diff)
get cheaper random bytes, less waste and no getpid() calls, which are
done by arc4random(); ok millert@ deraadt@
-rw-r--r--lib/libc/stdlib/malloc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index 39951bc9048..67f5de512ef 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: malloc.c,v 1.85 2006/12/19 13:00:50 otto Exp $ */
+/* $OpenBSD: malloc.c,v 1.86 2007/02/12 20:00:14 otto Exp $ */
/*
* ----------------------------------------------------------------------------
@@ -1672,6 +1672,7 @@ not_return:
static void
free_bytes(void *ptr)
{
+ u_int8_t __arc4_getbyte(void);
struct pginfo **mp, **pd, *info;
struct pdinfo *pi;
#ifdef MALLOC_EXTRA_SANITY
@@ -1687,7 +1688,7 @@ free_bytes(void *ptr)
/* delay return, returning a random something from before instead */
- tmpidx = arc4random() % 16;
+ tmpidx = __arc4_getbyte() % 16;
tmpptr = chunk_buffer[tmpidx];
chunk_buffer[tmpidx] = ptr;
ptr = tmpptr;