diff options
author | deraadt <> | 2014-05-29 21:07:43 +0000 |
---|---|---|
committer | deraadt <> | 2014-05-29 21:07:43 +0000 |
commit | 3d662abca6b2a7f5bc9108b036434d61fcdb6e53 (patch) | |
tree | d5fe0c330801f3e72c7b588264c6027636db4330 /src/lib/libcrypto/bn/bn_lib.c | |
parent | d205a2aecb99564cccfbea61c39ebe3b0ddd7fb7 (diff) | |
download | openbsd-3d662abca6b2a7f5bc9108b036434d61fcdb6e53.tar.gz openbsd-3d662abca6b2a7f5bc9108b036434d61fcdb6e53.tar.bz2 openbsd-3d662abca6b2a7f5bc9108b036434d61fcdb6e53.zip |
convert 53 malloc(a*b) to reallocarray(NULL, a, b). that is 53
potential integer overflows easily changed into an allocation return
of NULL, with errno nicely set if need be. checks for an allocations
returning NULL are commonplace, or if the object is dereferenced
(quite normal) will result in a nice fault which can be detected &
repaired properly.
ok tedu
Diffstat (limited to 'src/lib/libcrypto/bn/bn_lib.c')
-rw-r--r-- | src/lib/libcrypto/bn/bn_lib.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index a3a96662e8..28489f8181 100644 --- a/src/lib/libcrypto/bn/bn_lib.c +++ b/src/lib/libcrypto/bn/bn_lib.c | |||
@@ -245,7 +245,7 @@ BN_new(void) | |||
245 | { | 245 | { |
246 | BIGNUM *ret; | 246 | BIGNUM *ret; |
247 | 247 | ||
248 | if ((ret = (BIGNUM *)malloc(sizeof(BIGNUM))) == NULL) { | 248 | if ((ret = malloc(sizeof(BIGNUM))) == NULL) { |
249 | BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE); | 249 | BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE); |
250 | return (NULL); | 250 | return (NULL); |
251 | } | 251 | } |
@@ -278,7 +278,7 @@ bn_expand_internal(const BIGNUM *b, int words) | |||
278 | BN_R_EXPAND_ON_STATIC_BIGNUM_DATA); | 278 | BN_R_EXPAND_ON_STATIC_BIGNUM_DATA); |
279 | return (NULL); | 279 | return (NULL); |
280 | } | 280 | } |
281 | a = A = (BN_ULONG *)malloc(sizeof(BN_ULONG)*words); | 281 | a = A = reallocarray(NULL, sizeof(BN_ULONG), words); |
282 | if (A == NULL) { | 282 | if (A == NULL) { |
283 | BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE); | 283 | BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE); |
284 | return (NULL); | 284 | return (NULL); |