Browse Source

get cheaper random bytes, less waste and no getpid() calls, which are

done by arc4random(); ok millert@ deraadt@
OPENBSD_4_1
otto 18 years ago
parent
commit
58f0ac45ed
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      src/lib/libc/stdlib/malloc.c

+ 3
- 2
src/lib/libc/stdlib/malloc.c View File

@ -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 static void
free_bytes(void *ptr) free_bytes(void *ptr)
{ {
u_int8_t __arc4_getbyte(void);
struct pginfo **mp, **pd, *info; struct pginfo **mp, **pd, *info;
struct pdinfo *pi; struct pdinfo *pi;
#ifdef MALLOC_EXTRA_SANITY #ifdef MALLOC_EXTRA_SANITY
@ -1687,7 +1688,7 @@ free_bytes(void *ptr)
/* delay return, returning a random something from before instead */ /* delay return, returning a random something from before instead */
tmpidx = arc4random() % 16;
tmpidx = __arc4_getbyte() % 16;
tmpptr = chunk_buffer[tmpidx]; tmpptr = chunk_buffer[tmpidx];
chunk_buffer[tmpidx] = ptr; chunk_buffer[tmpidx] = ptr;
ptr = tmpptr; ptr = tmpptr;


Loading…
Cancel
Save