Browse Source

Check for overflow; from FreeBSD

OPENBSD_2_1
tholo 27 years ago
parent
commit
bde02a1ec3
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      src/lib/libc/stdlib/malloc.c

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

@ -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);


Loading…
Cancel
Save