]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream commit
authorderaadt@openbsd.org <deraadt@openbsd.org>
Fri, 21 Aug 2015 23:29:31 +0000 (23:29 +0000)
committerDamien Miller <djm@mindrot.org>
Sat, 22 Aug 2015 01:17:06 +0000 (11:17 +1000)
Improve size == 0, count == 0 checking in mm_zalloc,
 which is "array" like. Discussed with tedu, millert, otto.... and ok djm

Upstream-ID: 899b021be43b913fad3eca1aef44efe710c53e29

monitor.c

index a91420983ba86eda2619e629265897b3fefed53a..93489839215516f7464c6aacdf336dacf05932c4 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: monitor.c,v 1.150 2015/06/22 23:42:16 djm Exp $ */
+/* $OpenBSD: monitor.c,v 1.151 2015/08/21 23:29:31 deraadt Exp $ */
 /*
  * Copyright 2002 Niels Provos <provos@citi.umich.edu>
  * Copyright 2002 Markus Friedl <markus@openbsd.org>
@@ -487,15 +487,10 @@ monitor_sync(struct monitor *pmonitor)
 static void *
 mm_zalloc(struct mm_master *mm, u_int ncount, u_int size)
 {
-       size_t len = (size_t) size * ncount;
-       void *address;
-
-       if (len == 0 || ncount > SIZE_MAX / size)
+       if (size == 0 || ncount == 0 || ncount > SIZE_MAX / size)
                fatal("%s: mm_zalloc(%u, %u)", __func__, ncount, size);
 
-       address = mm_malloc(mm, len);
-
-       return (address);
+       return mm_malloc(mm, size * ncount);
 }
 
 static void