summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1997-04-05 05:05:45 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1997-04-05 05:05:45 +0000
commit664f0290d78338a2d6f6e1cf7920934f5fd3a6fb (patch)
tree0bee34a8ffed3d4396c21b782b2c426cafe05b32 /lib/libc/stdlib
parent758e07131b8b0646c934d18b5455cdebcbd08eae (diff)
Check for overflow; from FreeBSD
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/malloc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index da2c17b83d1..fc82a4f4190 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -8,7 +8,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: malloc.c,v 1.22 1997/02/11 17:46:36 niklas Exp $";
+static char rcsid[] = "$OpenBSD: malloc.c,v 1.23 1997/04/05 05:05:44 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -756,7 +756,9 @@ imalloc(size)
if (suicide)
abort();
- if (size <= malloc_maxsize)
+ if ((size + malloc_pagesize) < size) /* Check for overflow */
+ result = 0;
+ else if (size <= malloc_maxsize)
result = malloc_bytes(size);
else
result = malloc_pages(size);