diff --git a/crypto/bn/bn_conv.c b/crypto/bn/bn_conv.c index 57dda04b0d..8360712d82 100644 --- a/crypto/bn/bn_conv.c +++ b/crypto/bn/bn_conv.c @@ -63,7 +63,7 @@ char *BN_bn2dec(const BIGNUM *a) num = (i / 10 + i / 1000 + 1) + 1; tbytes = num + 3; /* negative and terminator and one spare? */ bn_data_num = num / BN_DEC_NUM + 1; - bn_data = OPENSSL_malloc(bn_data_num * sizeof(BN_ULONG)); + bn_data = OPENSSL_malloc_array(bn_data_num, sizeof(BN_ULONG)); buf = OPENSSL_malloc(tbytes); if (buf == NULL || bn_data == NULL) goto err; diff --git a/crypto/bn/bn_ctx.c b/crypto/bn/bn_ctx.c index aa70ca7a3f..036127560c 100644 --- a/crypto/bn/bn_ctx.c +++ b/crypto/bn/bn_ctx.c @@ -266,7 +266,7 @@ static int BN_STACK_push(BN_STACK *st, unsigned int idx) st->size ? (st->size * 3 / 2) : BN_CTX_START_FRAMES; unsigned int *newitems; - if ((newitems = OPENSSL_malloc(sizeof(*newitems) * newsize)) == NULL) + if ((newitems = OPENSSL_malloc_array(newsize, sizeof(*newitems))) == NULL) return 0; if (st->depth) memcpy(newitems, st->indexes, sizeof(*newitems) * st->depth); diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index 666c7bef03..f672371639 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -474,7 +474,7 @@ int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, bn_check_top(b); bn_check_top(p); - arr = OPENSSL_malloc(sizeof(*arr) * max); + arr = OPENSSL_malloc_array(max, sizeof(*arr)); if (arr == NULL) return 0; ret = BN_GF2m_poly2arr(p, arr, max); @@ -534,7 +534,7 @@ int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) bn_check_top(a); bn_check_top(p); - arr = OPENSSL_malloc(sizeof(*arr) * max); + arr = OPENSSL_malloc_array(max, sizeof(*arr)); if (arr == NULL) return 0; ret = BN_GF2m_poly2arr(p, arr, max); @@ -917,7 +917,7 @@ int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, bn_check_top(b); bn_check_top(p); - arr = OPENSSL_malloc(sizeof(*arr) * max); + arr = OPENSSL_malloc_array(max, sizeof(*arr)); if (arr == NULL) return 0; ret = BN_GF2m_poly2arr(p, arr, max); @@ -979,7 +979,7 @@ int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) bn_check_top(a); bn_check_top(p); - arr = OPENSSL_malloc(sizeof(*arr) * max); + arr = OPENSSL_malloc_array(max, sizeof(*arr)); if (arr == NULL) return 0; ret = BN_GF2m_poly2arr(p, arr, max); @@ -1113,7 +1113,7 @@ int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, bn_check_top(a); bn_check_top(p); - arr = OPENSSL_malloc(sizeof(*arr) * max); + arr = OPENSSL_malloc_array(max, sizeof(*arr)); if (arr == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c index 1b9a9e5010..67d74e3e7e 100644 --- a/crypto/bn/bn_lib.c +++ b/crypto/bn/bn_lib.c @@ -276,9 +276,9 @@ static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words) return NULL; } if (BN_get_flags(b, BN_FLG_SECURE)) - a = OPENSSL_secure_zalloc(words * sizeof(*a)); + a = OPENSSL_secure_calloc(words, sizeof(*a)); else - a = OPENSSL_zalloc(words * sizeof(*a)); + a = OPENSSL_calloc(words, sizeof(*a)); if (ossl_unlikely(a == NULL)) return NULL; diff --git a/crypto/bn/bn_mod.c b/crypto/bn/bn_mod.c index c3aa090046..17ddcc8b03 100644 --- a/crypto/bn/bn_mod.c +++ b/crypto/bn/bn_mod.c @@ -63,7 +63,7 @@ int bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, return 0; if (mtop > OSSL_NELEM(storage)) { - tp = OPENSSL_malloc(mtop * sizeof(BN_ULONG)); + tp = OPENSSL_malloc_array(mtop, sizeof(BN_ULONG)); if (tp == NULL) return 0; } diff --git a/crypto/bn/bn_prime.c b/crypto/bn/bn_prime.c index 96eb1b3c34..3b0db71194 100644 --- a/crypto/bn/bn_prime.c +++ b/crypto/bn/bn_prime.c @@ -144,7 +144,7 @@ int BN_generate_prime_ex2(BIGNUM *ret, int bits, int safe, return 0; } - mods = OPENSSL_zalloc(sizeof(*mods) * NUMPRIMES); + mods = OPENSSL_calloc(NUMPRIMES, sizeof(*mods)); if (mods == NULL) return 0; diff --git a/crypto/bn/bn_s390x.c b/crypto/bn/bn_s390x.c index 0b60f4ec1d..5d69824123 100644 --- a/crypto/bn/bn_s390x.c +++ b/crypto/bn/bn_s390x.c @@ -31,7 +31,7 @@ static int s390x_mod_exp_hw(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, if (OPENSSL_s390xcex == -1 || OPENSSL_s390xcex_nodev) return 0; size = BN_num_bytes(m); - buffer = OPENSSL_zalloc(4 * size); + buffer = OPENSSL_calloc(size, 4); if (buffer == NULL) return 0; me.inputdata = buffer;