From e36774a3cfbf9430a020ae98951cce7b70f75c00 Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Thu, 29 May 2014 21:19:30 +0000 Subject: ok, next pass after review: when possible, put the reallocarray arguments in the "size_t nmemb, size_t size" --- src/lib/libcrypto/bn/bn_gf2m.c | 10 +++++----- src/lib/libcrypto/bn/bn_lib.c | 2 +- src/lib/libcrypto/ec/ec_mult.c | 2 +- src/lib/libcrypto/lhash/lhash.c | 2 +- src/lib/libcrypto/objects/obj_xref.c | 2 +- src/lib/libcrypto/txt_db/txt_db.c | 4 ++-- src/lib/libcrypto/x509v3/pcy_tree.c | 2 +- src/lib/libssl/src/apps/apps.c | 2 +- src/lib/libssl/src/apps/ca.c | 2 +- src/lib/libssl/src/apps/ecparam.c | 2 +- src/lib/libssl/src/crypto/bn/bn_gf2m.c | 10 +++++----- src/lib/libssl/src/crypto/bn/bn_lib.c | 2 +- src/lib/libssl/src/crypto/ec/ec_mult.c | 2 +- src/lib/libssl/src/crypto/lhash/lhash.c | 2 +- src/lib/libssl/src/crypto/objects/obj_xref.c | 2 +- src/lib/libssl/src/crypto/txt_db/txt_db.c | 4 ++-- src/lib/libssl/src/crypto/x509v3/pcy_tree.c | 2 +- 17 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/lib/libcrypto/bn/bn_gf2m.c b/src/lib/libcrypto/bn/bn_gf2m.c index 4bd50924d3..f451befb0d 100644 --- a/src/lib/libcrypto/bn/bn_gf2m.c +++ b/src/lib/libcrypto/bn/bn_gf2m.c @@ -547,7 +547,7 @@ BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, bn_check_top(a); bn_check_top(b); bn_check_top(p); - if ((arr = reallocarray(NULL, sizeof(int), max)) == NULL) + if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { @@ -609,7 +609,7 @@ BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) bn_check_top(a); bn_check_top(p); - if ((arr = reallocarray(NULL, sizeof(int), max)) == NULL) + if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { @@ -1037,7 +1037,7 @@ BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, bn_check_top(a); bn_check_top(b); bn_check_top(p); - if ((arr = reallocarray(NULL, sizeof(int), max)) == NULL) + if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { @@ -1099,7 +1099,7 @@ BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) int *arr = NULL; bn_check_top(a); bn_check_top(p); - if ((arr = reallocarray(NULL, sizeof(int), max)) == NULL) + if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { @@ -1234,7 +1234,7 @@ BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) bn_check_top(a); bn_check_top(p); - if ((arr = reallocarray(NULL, sizeof(int), max)) == NULL) + if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index 28489f8181..a4f0bdd34b 100644 --- a/src/lib/libcrypto/bn/bn_lib.c +++ b/src/lib/libcrypto/bn/bn_lib.c @@ -278,7 +278,7 @@ bn_expand_internal(const BIGNUM *b, int words) BN_R_EXPAND_ON_STATIC_BIGNUM_DATA); return (NULL); } - a = A = reallocarray(NULL, sizeof(BN_ULONG), words); + a = A = reallocarray(NULL, words, sizeof(BN_ULONG)); if (A == NULL) { BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE); return (NULL); diff --git a/src/lib/libcrypto/ec/ec_mult.c b/src/lib/libcrypto/ec/ec_mult.c index b3bd34d82d..0fd0cab2f1 100644 --- a/src/lib/libcrypto/ec/ec_mult.c +++ b/src/lib/libcrypto/ec/ec_mult.c @@ -790,7 +790,7 @@ ec_wNAF_precompute_mult(EC_GROUP * group, BN_CTX * ctx) num = pre_points_per_block * numblocks; /* number of points to * compute and store */ - points = reallocarray(NULL, sizeof(EC_POINT *), (num + 1)); + points = reallocarray(NULL, (num + 1), sizeof(EC_POINT *)); if (!points) { ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE); goto err; diff --git a/src/lib/libcrypto/lhash/lhash.c b/src/lib/libcrypto/lhash/lhash.c index e75a43f506..1e3359cfe0 100644 --- a/src/lib/libcrypto/lhash/lhash.c +++ b/src/lib/libcrypto/lhash/lhash.c @@ -119,7 +119,7 @@ lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c) if ((ret = malloc(sizeof(_LHASH))) == NULL) goto err0; - if ((ret->b = reallocarray(NULL, sizeof(LHASH_NODE *), MIN_NODES)) == NULL) + if ((ret->b = reallocarray(NULL, MIN_NODES, sizeof(LHASH_NODE *))) == NULL) goto err1; for (i = 0; i < MIN_NODES; i++) ret->b[i] = NULL; diff --git a/src/lib/libcrypto/objects/obj_xref.c b/src/lib/libcrypto/objects/obj_xref.c index 8e9128efc4..2c1631e773 100644 --- a/src/lib/libcrypto/objects/obj_xref.c +++ b/src/lib/libcrypto/objects/obj_xref.c @@ -164,7 +164,7 @@ OBJ_add_sigid(int signid, int dig_id, int pkey_id) sigx_app = sk_nid_triple_new(sigx_cmp); if (!sigx_app) return 0; - ntr = reallocarray(NULL, sizeof(int), 3); + ntr = reallocarray(NULL, 3, sizeof(int)); if (!ntr) return 0; ntr->sign_id = signid; diff --git a/src/lib/libcrypto/txt_db/txt_db.c b/src/lib/libcrypto/txt_db/txt_db.c index 0f3a7ffbb3..e29a60316a 100644 --- a/src/lib/libcrypto/txt_db/txt_db.c +++ b/src/lib/libcrypto/txt_db/txt_db.c @@ -94,9 +94,9 @@ TXT_DB_read(BIO *in, int num) ret->qual = NULL; if ((ret->data = sk_OPENSSL_PSTRING_new_null()) == NULL) goto err; - if ((ret->index = reallocarray(NULL, sizeof(*ret->index), num)) == NULL) + if ((ret->index = reallocarray(NULL, num, sizeof(*ret->index))) == NULL) goto err; - if ((ret->qual = reallocarray(NULL, sizeof(*(ret->qual)), num)) == NULL) + if ((ret->qual = reallocarray(NULL, num, sizeof(*(ret->qual)))) == NULL) goto err; for (i = 0; i < num; i++) { ret->index[i] = NULL; diff --git a/src/lib/libcrypto/x509v3/pcy_tree.c b/src/lib/libcrypto/x509v3/pcy_tree.c index 080a87d674..4aa83e027d 100644 --- a/src/lib/libcrypto/x509v3/pcy_tree.c +++ b/src/lib/libcrypto/x509v3/pcy_tree.c @@ -220,7 +220,7 @@ tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs, unsigned int flags) return 0; tree->flags = 0; - tree->levels = reallocarray(NULL, sizeof(X509_POLICY_LEVEL), n); + tree->levels = reallocarray(NULL, n, sizeof(X509_POLICY_LEVEL)); tree->nlevel = 0; tree->extra_data = NULL; tree->auth_policies = NULL; diff --git a/src/lib/libssl/src/apps/apps.c b/src/lib/libssl/src/apps/apps.c index a5ffee3e5f..3b28a6f3cc 100644 --- a/src/lib/libssl/src/apps/apps.c +++ b/src/lib/libssl/src/apps/apps.c @@ -214,7 +214,7 @@ chopup_args(ARGS *arg, char *buf, int *argc, char **argv[]) i = 0; if (arg->count == 0) { arg->count = 20; - arg->data = reallocarray(NULL, sizeof(char *), arg->count); + arg->data = reallocarray(NULL, arg->count, sizeof(char *)); } for (i = 0; i < arg->count; i++) arg->data[i] = NULL; diff --git a/src/lib/libssl/src/apps/ca.c b/src/lib/libssl/src/apps/ca.c index 89c4f84613..bf32446f3b 100644 --- a/src/lib/libssl/src/apps/ca.c +++ b/src/lib/libssl/src/apps/ca.c @@ -1974,7 +1974,7 @@ again2: row[DB_type][0] = 'V'; row[DB_type][1] = '\0'; - if ((irow = reallocarray(NULL, sizeof(char *), (DB_NUMBER + 1))) == + if ((irow = reallocarray(NULL, DB_NUMBER + 1, sizeof(char *))) == NULL) { BIO_printf(bio_err, "Memory allocation failure\n"); goto err; diff --git a/src/lib/libssl/src/apps/ecparam.c b/src/lib/libssl/src/apps/ecparam.c index 29eaf9ba1a..e5c26c3ad0 100644 --- a/src/lib/libssl/src/apps/ecparam.c +++ b/src/lib/libssl/src/apps/ecparam.c @@ -308,7 +308,7 @@ bad: crv_len = EC_get_builtin_curves(NULL, 0); - curves = reallocarray(NULL, sizeof(EC_builtin_curve), crv_len); + curves = reallocarray(NULL, crv_len, sizeof(EC_builtin_curve)); if (curves == NULL) goto end; diff --git a/src/lib/libssl/src/crypto/bn/bn_gf2m.c b/src/lib/libssl/src/crypto/bn/bn_gf2m.c index 4bd50924d3..f451befb0d 100644 --- a/src/lib/libssl/src/crypto/bn/bn_gf2m.c +++ b/src/lib/libssl/src/crypto/bn/bn_gf2m.c @@ -547,7 +547,7 @@ BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, bn_check_top(a); bn_check_top(b); bn_check_top(p); - if ((arr = reallocarray(NULL, sizeof(int), max)) == NULL) + if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { @@ -609,7 +609,7 @@ BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) bn_check_top(a); bn_check_top(p); - if ((arr = reallocarray(NULL, sizeof(int), max)) == NULL) + if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { @@ -1037,7 +1037,7 @@ BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, bn_check_top(a); bn_check_top(b); bn_check_top(p); - if ((arr = reallocarray(NULL, sizeof(int), max)) == NULL) + if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { @@ -1099,7 +1099,7 @@ BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) int *arr = NULL; bn_check_top(a); bn_check_top(p); - if ((arr = reallocarray(NULL, sizeof(int), max)) == NULL) + if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { @@ -1234,7 +1234,7 @@ BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) bn_check_top(a); bn_check_top(p); - if ((arr = reallocarray(NULL, sizeof(int), max)) == NULL) + if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); if (!ret || ret > max) { diff --git a/src/lib/libssl/src/crypto/bn/bn_lib.c b/src/lib/libssl/src/crypto/bn/bn_lib.c index 28489f8181..a4f0bdd34b 100644 --- a/src/lib/libssl/src/crypto/bn/bn_lib.c +++ b/src/lib/libssl/src/crypto/bn/bn_lib.c @@ -278,7 +278,7 @@ bn_expand_internal(const BIGNUM *b, int words) BN_R_EXPAND_ON_STATIC_BIGNUM_DATA); return (NULL); } - a = A = reallocarray(NULL, sizeof(BN_ULONG), words); + a = A = reallocarray(NULL, words, sizeof(BN_ULONG)); if (A == NULL) { BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE); return (NULL); diff --git a/src/lib/libssl/src/crypto/ec/ec_mult.c b/src/lib/libssl/src/crypto/ec/ec_mult.c index b3bd34d82d..0fd0cab2f1 100644 --- a/src/lib/libssl/src/crypto/ec/ec_mult.c +++ b/src/lib/libssl/src/crypto/ec/ec_mult.c @@ -790,7 +790,7 @@ ec_wNAF_precompute_mult(EC_GROUP * group, BN_CTX * ctx) num = pre_points_per_block * numblocks; /* number of points to * compute and store */ - points = reallocarray(NULL, sizeof(EC_POINT *), (num + 1)); + points = reallocarray(NULL, (num + 1), sizeof(EC_POINT *)); if (!points) { ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE); goto err; diff --git a/src/lib/libssl/src/crypto/lhash/lhash.c b/src/lib/libssl/src/crypto/lhash/lhash.c index e75a43f506..1e3359cfe0 100644 --- a/src/lib/libssl/src/crypto/lhash/lhash.c +++ b/src/lib/libssl/src/crypto/lhash/lhash.c @@ -119,7 +119,7 @@ lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c) if ((ret = malloc(sizeof(_LHASH))) == NULL) goto err0; - if ((ret->b = reallocarray(NULL, sizeof(LHASH_NODE *), MIN_NODES)) == NULL) + if ((ret->b = reallocarray(NULL, MIN_NODES, sizeof(LHASH_NODE *))) == NULL) goto err1; for (i = 0; i < MIN_NODES; i++) ret->b[i] = NULL; diff --git a/src/lib/libssl/src/crypto/objects/obj_xref.c b/src/lib/libssl/src/crypto/objects/obj_xref.c index 8e9128efc4..2c1631e773 100644 --- a/src/lib/libssl/src/crypto/objects/obj_xref.c +++ b/src/lib/libssl/src/crypto/objects/obj_xref.c @@ -164,7 +164,7 @@ OBJ_add_sigid(int signid, int dig_id, int pkey_id) sigx_app = sk_nid_triple_new(sigx_cmp); if (!sigx_app) return 0; - ntr = reallocarray(NULL, sizeof(int), 3); + ntr = reallocarray(NULL, 3, sizeof(int)); if (!ntr) return 0; ntr->sign_id = signid; diff --git a/src/lib/libssl/src/crypto/txt_db/txt_db.c b/src/lib/libssl/src/crypto/txt_db/txt_db.c index 0f3a7ffbb3..e29a60316a 100644 --- a/src/lib/libssl/src/crypto/txt_db/txt_db.c +++ b/src/lib/libssl/src/crypto/txt_db/txt_db.c @@ -94,9 +94,9 @@ TXT_DB_read(BIO *in, int num) ret->qual = NULL; if ((ret->data = sk_OPENSSL_PSTRING_new_null()) == NULL) goto err; - if ((ret->index = reallocarray(NULL, sizeof(*ret->index), num)) == NULL) + if ((ret->index = reallocarray(NULL, num, sizeof(*ret->index))) == NULL) goto err; - if ((ret->qual = reallocarray(NULL, sizeof(*(ret->qual)), num)) == NULL) + if ((ret->qual = reallocarray(NULL, num, sizeof(*(ret->qual)))) == NULL) goto err; for (i = 0; i < num; i++) { ret->index[i] = NULL; diff --git a/src/lib/libssl/src/crypto/x509v3/pcy_tree.c b/src/lib/libssl/src/crypto/x509v3/pcy_tree.c index 080a87d674..4aa83e027d 100644 --- a/src/lib/libssl/src/crypto/x509v3/pcy_tree.c +++ b/src/lib/libssl/src/crypto/x509v3/pcy_tree.c @@ -220,7 +220,7 @@ tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs, unsigned int flags) return 0; tree->flags = 0; - tree->levels = reallocarray(NULL, sizeof(X509_POLICY_LEVEL), n); + tree->levels = reallocarray(NULL, n, sizeof(X509_POLICY_LEVEL)); tree->nlevel = 0; tree->extra_data = NULL; tree->auth_policies = NULL; -- cgit v1.2.3-55-g6feb