diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-08-21 23:29:32 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-08-21 23:29:32 +0000 |
commit | c9c8357ec49564cae0efbd36f77d54e4cba0c529 (patch) | |
tree | 74801160bdf251a41b1e21b1feb9adb4f3a9a380 | |
parent | 54c7c0e0064381c2fa15a52dc78961c9dcd0eea3 (diff) |
Improve size == 0, count == 0 checking in mm_zalloc, which is "array" like.
Discussed with tedu, millert, otto.... and ok djm
-rw-r--r-- | usr.bin/ssh/monitor.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/usr.bin/ssh/monitor.c b/usr.bin/ssh/monitor.c index 53f63bf0fde..05f8900795b 100644 --- a/usr.bin/ssh/monitor.c +++ b/usr.bin/ssh/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> @@ -391,15 +391,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 |