summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/malloc.c
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2007-02-12 20:00:14 +0000
committerotto <otto@openbsd.org>2007-02-12 20:00:14 +0000
commit7c5d135c07e34643d755e213917257a1b4711edd (patch)
treee7b841078d1fe3576f2420c6003dcfbf384050f8 /lib/libc/stdlib/malloc.c
parentprovide an libc internal interface to get random bytes, to be used by malloc (diff)
downloadwireguard-openbsd-7c5d135c07e34643d755e213917257a1b4711edd.tar.xz
wireguard-openbsd-7c5d135c07e34643d755e213917257a1b4711edd.zip
get cheaper random bytes, less waste and no getpid() calls, which are
done by arc4random(); ok millert@ deraadt@
Diffstat (limited to 'lib/libc/stdlib/malloc.c')
-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;