X-Git-Url: http://andersk.mit.edu/gitweb/openssh.git/blobdiff_plain/30eab01dd513b1e58f1c5c63a789c9d005f29a38..f464b2f1e7aa702f53d84d7fc5284b24d3c94061:/monitor_mm.c diff --git a/monitor_mm.c b/monitor_mm.c index fbf57b43..b0ec37cf 100644 --- a/monitor_mm.c +++ b/monitor_mm.c @@ -24,13 +24,12 @@ */ #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.9 2004/05/11 19:01:43 deraadt Exp $"); #ifdef HAVE_SYS_MMAN_H #include #endif -#include "openbsd-compat/xmmap.h" #include "ssh.h" #include "xmalloc.h" #include "log.h" @@ -93,7 +92,7 @@ mm_create(struct mm_master *mmalloc, size_t size) mm->mmalloc = mmalloc; address = xmmap(size); - if (address == MAP_FAILED) + if (address == (void *)MAP_FAILED) fatal("mmap(%lu): %s", (u_long)size, strerror(errno)); mm->address = address; @@ -167,8 +166,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)