X-Git-Url: http://andersk.mit.edu/gitweb/openssh.git/blobdiff_plain/4165b82e3e23595eddac85faabaf1f4fc057e366..HEAD:/monitor_mm.c diff --git a/monitor_mm.c b/monitor_mm.c index fb5f2c82..faf9f3dc 100644 --- a/monitor_mm.c +++ b/monitor_mm.c @@ -1,3 +1,4 @@ +/* $OpenBSD: monitor_mm.c,v 1.16 2009/06/22 05:39:28 dtucker Exp $ */ /* * Copyright 2002 Niels Provos * All rights reserved. @@ -24,14 +25,20 @@ */ #include "includes.h" -RCSID("$OpenBSD: monitor_mm.c,v 1.7 2002/06/28 01:49:31 millert Exp $"); +#include #ifdef HAVE_SYS_MMAN_H #include #endif +#include +#include "openbsd-compat/sys-tree.h" + +#include +#include +#include -#include "ssh.h" #include "xmalloc.h" +#include "ssh.h" #include "log.h" #include "monitor_mm.h" @@ -92,7 +99,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; @@ -166,8 +173,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)