summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/hcreate.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2007-09-02 15:19:07 +0000
committerderaadt <deraadt@openbsd.org>2007-09-02 15:19:07 +0000
commit1ed98fdf61d9dd29369f246109081408082ce54d (patch)
treead7631e58c83830d1fc51cbadb9a2da53c1abfb7 /lib/libc/stdlib/hcreate.c
parentOpenCVS server init-support with OpenCVS and GNU cvs clients. (diff)
downloadwireguard-openbsd-1ed98fdf61d9dd29369f246109081408082ce54d.tar.xz
wireguard-openbsd-1ed98fdf61d9dd29369f246109081408082ce54d.zip
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
Diffstat (limited to 'lib/libc/stdlib/hcreate.c')
-rw-r--r--lib/libc/stdlib/hcreate.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/stdlib/hcreate.c b/lib/libc/stdlib/hcreate.c
index f8df1bcd7c9..094f32c173e 100644
--- a/lib/libc/stdlib/hcreate.c
+++ b/lib/libc/stdlib/hcreate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hcreate.c,v 1.3 2005/10/10 17:37:44 espie Exp $ */
+/* $OpenBSD: hcreate.c,v 1.4 2007/09/02 15:19:17 deraadt Exp $ */
/* $NetBSD: hcreate.c,v 1.5 2004/04/23 02:48:12 simonb Exp $ */
/*
@@ -117,7 +117,7 @@ hcreate(size_t nel)
/* Allocate the table. */
htablesize = nel;
- htable = malloc(htablesize * sizeof htable[0]);
+ htable = calloc(htablesize, sizeof htable[0]);
if (htable == NULL) {
errno = ENOMEM;
return 0;