summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/malloc.c
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2011-07-12 14:43:42 +0000
committerotto <otto@openbsd.org>2011-07-12 14:43:42 +0000
commit0d055aeea4929ba608aaf10f5b168c15c3f68d49 (patch)
tree8adfb2c894256c2b1db983e7e433bc3e4c075632 /lib/libc/stdlib/malloc.c
parentAllow syslogc -n XX to display less than the whole file, and -n XX -f to (diff)
downloadwireguard-openbsd-0d055aeea4929ba608aaf10f5b168c15c3f68d49.tar.xz
wireguard-openbsd-0d055aeea4929ba608aaf10f5b168c15c3f68d49.zip
on malloc flag S, set cache size to 0; will catch even more
use-after-free bugs; ok krw@ dlg@ pirofti@
Diffstat (limited to 'lib/libc/stdlib/malloc.c')
-rw-r--r--lib/libc/stdlib/malloc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index 976880e757b..9682f91cda0 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: malloc.c,v 1.138 2011/06/20 18:04:06 tedu Exp $ */
+/* $OpenBSD: malloc.c,v 1.139 2011/07/12 14:43:42 otto Exp $ */
/*
* Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>
*
@@ -68,6 +68,8 @@
#define MALLOC_MAXCACHE 256
#define MALLOC_DELAYED_CHUNKS 15 /* max of getrnibble() */
#define MALLOC_INITIAL_REGIONS 512
+#define MALLOC_DEFAULT_CACHE 64
+
/*
* When the P option is active, we move allocations between half a page
* and a whole page towards the end, subject to alignment constraints.
@@ -461,7 +463,7 @@ omalloc_init(struct dir_info **dp)
*/
mopts.malloc_abort = 1;
mopts.malloc_move = 1;
- mopts.malloc_cache = 64;
+ mopts.malloc_cache = MALLOC_DEFAULT_CACHE;
for (i = 0; i < 3; i++) {
switch (i) {
@@ -551,10 +553,12 @@ omalloc_init(struct dir_info **dp)
case 's':
mopts.malloc_freeprot = mopts.malloc_junk = 0;
mopts.malloc_guard = 0;
+ mopts.malloc_cache = MALLOC_DEFAULT_CACHE;
break;
case 'S':
mopts.malloc_freeprot = mopts.malloc_junk = 1;
mopts.malloc_guard = MALLOC_PAGESIZE;
+ mopts.malloc_cache = 0;
break;
case 'x':
mopts.malloc_xmalloc = 0;