mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
Check for overflow in size argument.
Tested by: Joel Maslak <j@pobox.com> Closes: PR kern/2964
This commit is contained in:
parent
5f1376d7ec
commit
753da60320
1 changed files with 4 additions and 2 deletions
|
|
@ -6,7 +6,7 @@
|
|||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id$
|
||||
* $Id: malloc.c,v 1.21 1997/02/22 15:03:12 peter Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -731,7 +731,9 @@ imalloc(size_t 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…
Reference in a new issue