summaryrefslogtreecommitdiff
path: root/lib/libc/string
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2007-09-02 15:19:41 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2007-09-02 15:19:41 +0000
commit6ebd04219f0d749c87a763e8afb578dfcd5223cc (patch)
treebb0f29e0a3791fff88551c93f5d4ba7113bdba43 /lib/libc/string
parentbe524287dc216d876f995eddcaf32762c702c6e9 (diff)
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
Diffstat (limited to 'lib/libc/string')
-rw-r--r--lib/libc/string/bm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/string/bm.c b/lib/libc/string/bm.c
index 829c24082e5..2c4c6ca7207 100644
--- a/lib/libc/string/bm.c
+++ b/lib/libc/string/bm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bm.c,v 1.6 2005/08/08 08:05:37 espie Exp $ */
+/* $OpenBSD: bm.c,v 1.7 2007/09/02 15:19:18 deraadt Exp $ */
/*-
* Copyright (c) 1994
* The Regents of the University of California. All rights reserved.
@@ -104,7 +104,7 @@ bm_comp(u_char const *pb, size_t len, u_char const *freq)
goto mem;
memcpy(pat->pat, pb, pat->patlen);
/* get skip delta */
- if ((pat->delta = malloc(256 * sizeof(*d))) == NULL)
+ if ((pat->delta = calloc(256, sizeof(*d))) == NULL)
goto mem;
for (j = 0, d = pat->delta; j < 256; j++)
d[j] = pat->patlen;