diff options
| author | deraadt <> | 2007-09-02 15:19:18 +0000 | 
|---|---|---|
| committer | deraadt <> | 2007-09-02 15:19:18 +0000 | 
| commit | 4dce4206f0cafd0811f23aedc04a436aa9d145c1 (patch) | |
| tree | 9bdb3d7b5724b183b1a397bf8f071fac1f056834 /src/lib/libc/string | |
| parent | 7c27b50830c6058e8a7d8f2a3398c9c2f429b9f4 (diff) | |
| download | openbsd-4dce4206f0cafd0811f23aedc04a436aa9d145c1.tar.gz openbsd-4dce4206f0cafd0811f23aedc04a436aa9d145c1.tar.bz2 openbsd-4dce4206f0cafd0811f23aedc04a436aa9d145c1.zip  | |
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/string/bm.c | 4 | 
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libc/string/bm.c b/src/lib/libc/string/bm.c index 829c24082e..2c4c6ca720 100644 --- a/src/lib/libc/string/bm.c +++ b/src/lib/libc/string/bm.c  | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bm.c,v 1.6 2005/08/08 08:05:37 espie Exp $ */ | 1 | /* $OpenBSD: bm.c,v 1.7 2007/09/02 15:19:18 deraadt Exp $ */ | 
| 2 | /*- | 2 | /*- | 
| 3 | * Copyright (c) 1994 | 3 | * Copyright (c) 1994 | 
| 4 | * The Regents of the University of California. All rights reserved. | 4 | * 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) | |||
| 104 | goto mem; | 104 | goto mem; | 
| 105 | memcpy(pat->pat, pb, pat->patlen); | 105 | memcpy(pat->pat, pb, pat->patlen); | 
| 106 | /* get skip delta */ | 106 | /* get skip delta */ | 
| 107 | if ((pat->delta = malloc(256 * sizeof(*d))) == NULL) | 107 | if ((pat->delta = calloc(256, sizeof(*d))) == NULL) | 
| 108 | goto mem; | 108 | goto mem; | 
| 109 | for (j = 0, d = pat->delta; j < 256; j++) | 109 | for (j = 0, d = pat->delta; j < 256; j++) | 
| 110 | d[j] = pat->patlen; | 110 | d[j] = pat->patlen; | 
