diff options
author | 2012-12-22 07:32:17 +0000 | |
---|---|---|
committer | 2012-12-22 07:32:17 +0000 | |
commit | 7fc588d71466f7806be3f5157973f5878398caee (patch) | |
tree | 3684be4fb70280b2609279052362248584943817 /lib/libc/stdlib/malloc.c | |
parent | When binding to a new lease, wait for the RTM_NEWADDR message in (diff) | |
download | wireguard-openbsd-7fc588d71466f7806be3f5157973f5878398caee.tar.xz wireguard-openbsd-7fc588d71466f7806be3f5157973f5878398caee.zip |
Fix bug in random offset introduced in rev 1.143; random range was
expanded, but not enough due to precedence error. Spotted by Thorsten Glaser.
Diffstat (limited to 'lib/libc/stdlib/malloc.c')
-rw-r--r-- | lib/libc/stdlib/malloc.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index b14c7476524..af175875520 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.148 2012/11/02 18:18:15 djm Exp $ */ +/* $OpenBSD: malloc.c,v 1.149 2012/12/22 07:32:17 otto Exp $ */ /* * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net> * @@ -321,7 +321,7 @@ unmap(struct dir_info *d, void *p, size_t sz) rsz = mopts.malloc_cache - d->free_regions_size; if (psz > rsz) tounmap = psz - rsz; - offset = getrnibble() + getrnibble() << 4; + offset = getrnibble() + (getrnibble() << 4); for (i = 0; tounmap > 0 && i < mopts.malloc_cache; i++) { r = &d->free_regions[(i + offset) & (mopts.malloc_cache - 1)]; if (r->p != NULL) { @@ -402,7 +402,7 @@ map(struct dir_info *d, size_t sz, int zero_fill) /* zero fill not needed */ return p; } - offset = getrnibble() + getrnibble() << 4; + offset = getrnibble() + (getrnibble() << 4); for (i = 0; i < mopts.malloc_cache; i++) { r = &d->free_regions[(i + offset) & (mopts.malloc_cache - 1)]; if (r->p != NULL) { |