summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-07-26 13:33:53 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-07-26 13:33:53 +0000
commit9890549a8048a1f1ba461aa5802b918d2e634158 (patch)
tree58bfcca959e48c0d03390a2c84e420f1a014b2a8 /sys
parent0c5559768b18f1e1a66ab2931dae735ad8c3da6d (diff)
Be more careful with ranges.
From Heikki Korpela <heko@iki.fi>
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_malloc_debug.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/sys/kern/kern_malloc_debug.c b/sys/kern/kern_malloc_debug.c
index 7043b150697..02e410f0588 100644
--- a/sys/kern/kern_malloc_debug.c
+++ b/sys/kern/kern_malloc_debug.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_malloc_debug.c,v 1.9 2001/07/18 13:50:40 art Exp $ */
+/* $OpenBSD: kern_malloc_debug.c,v 1.10 2001/07/26 13:33:52 art Exp $ */
/*
* Copyright (c) 1999, 2000 Artur Grabowski <art@openbsd.org>
@@ -66,7 +66,12 @@
/*
* malloc_deb_type and malloc_deb_size define the type and size of
- * memory to be debugged. Use 0 for a wildcard.
+ * memory to be debugged. Use 0 for a wildcard. malloc_deb_size_lo
+ * is the lower limit and malloc_deb_size_hi the upper limit of sizes
+ * being debugged; 0 will not work as a wildcard for the upper limit.
+ * For any debugging to take place, type must be != -1, size must be >= 0,
+ * and if the limits are being used, size must be set to 0.
+ * See /usr/src/sys/sys/malloc.h and malloc(9) for a list of types.
*
* Although those are variables, it's a really bad idea to change the type
* if any memory chunks of this type are used. It's ok to change the size
@@ -122,9 +127,11 @@ debug_malloc(size, type, flags, addr)
int s;
int wait = flags & M_NOWAIT;
+ /* Careful not to compare unsigned long to int -1 */
if ((type != malloc_deb_type && malloc_deb_type != 0) ||
(size != malloc_deb_size && malloc_deb_size != 0) ||
- (size < malloc_deb_size_lo || size > malloc_deb_size_hi) ||
+ (malloc_deb_size_lo != -1 && size < malloc_deb_size_lo) ||
+ (malloc_deb_size_hi != -1 && size > malloc_deb_size_hi) ||
type == M_DEBUG)
return 0;