summaryrefslogtreecommitdiff
path: root/monitor_mm.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2002-08-20 18:36:25 +0000
committerBen Lindstrom <mouring@eviladmin.org>2002-08-20 18:36:25 +0000
commit0a4f7542da24b870c3d18bedfcbd4c87aa7ebcd3 (patch)
tree58843c57ff628b1e59ebc93167fe87e22ef71938 /monitor_mm.c
parentd730b780716d3955066f9fcc89aa377b31079cff (diff)
downloadopenssh-git-0a4f7542da24b870c3d18bedfcbd4c87aa7ebcd3.tar.gz
- millert@cvs.openbsd.org 2002/08/02 14:43:15
[monitor.c monitor_mm.c] Change mm_zalloc() sanity checks to be more in line with what we do in calloc() and add a check to monitor_mm.c. OK provos@ and markus@
Diffstat (limited to 'monitor_mm.c')
-rw-r--r--monitor_mm.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/monitor_mm.c b/monitor_mm.c
index fbf57b43..b4a6e40c 100644
--- a/monitor_mm.c
+++ b/monitor_mm.c
@@ -24,7 +24,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: monitor_mm.c,v 1.7 2002/06/28 01:49:31 millert Exp $");
+RCSID("$OpenBSD: monitor_mm.c,v 1.8 2002/08/02 14:43:15 millert Exp $");
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
@@ -167,8 +167,10 @@ mm_malloc(struct mm_master *mm, size_t size)
if (size == 0)
fatal("mm_malloc: try to allocate 0 space");
+ if (size > SIZE_T_MAX - MM_MINSIZE + 1)
+ fatal("mm_malloc: size too big");
- size = ((size + MM_MINSIZE - 1) / MM_MINSIZE) * MM_MINSIZE;
+ size = ((size + (MM_MINSIZE - 1)) / MM_MINSIZE) * MM_MINSIZE;
RB_FOREACH(mms, mmtree, &mm->rb_free) {
if (mms->size >= size)