mirror of https://github.com/openssl/openssl.git
apps, fuzz, providers: use array memory (re)allocation routines
Co-Authored-by: Alexandr Nedvedicky <sashan@openssl.org> Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org> Reviewed-by: Saša Nedvědický <sashan@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <ppzgs1@gmail.com> Reviewed-by: Neil Horman <nhorman@openssl.org> (Merged from https://github.com/openssl/openssl/pull/28059)
This commit is contained in:
parent
5fab189ddd
commit
f3a4d05c58
|
|
@ -106,7 +106,8 @@ int chopup_args(ARGS *arg, char *buf)
|
|||
char **tmp;
|
||||
|
||||
arg->size += 20;
|
||||
tmp = OPENSSL_realloc(arg->argv, sizeof(*arg->argv) * arg->size);
|
||||
tmp = OPENSSL_realloc_array(arg->argv,
|
||||
arg->size, sizeof(*arg->argv));
|
||||
if (tmp == NULL)
|
||||
return 0;
|
||||
arg->argv = tmp;
|
||||
|
|
@ -3461,7 +3462,7 @@ OSSL_PARAM *app_params_new_from_opts(STACK_OF(OPENSSL_STRING) *opts,
|
|||
if (opts == NULL)
|
||||
return NULL;
|
||||
|
||||
params = OPENSSL_zalloc(sizeof(OSSL_PARAM) * (sz + 1));
|
||||
params = OPENSSL_calloc(sz + 1, sizeof(OSSL_PARAM));
|
||||
if (params == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ char **copy_argv(int *argc, char *argv[])
|
|||
* get them when linking with all of libapps.a.
|
||||
* See comment in test/build.info.
|
||||
*/
|
||||
newargv = OPENSSL_malloc(sizeof(*newargv) * (count + 1));
|
||||
newargv = OPENSSL_malloc_array(count + 1, sizeof(*newargv));
|
||||
if (newargv == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -1303,7 +1303,7 @@ static int print_x509v3_exts(BIO *bio, X509 *x, const char *ext_names)
|
|||
BIO_printf(bio, "Invalid extension names: %s\n", ext_names);
|
||||
goto end;
|
||||
}
|
||||
if ((names = OPENSSL_malloc(sizeof(char *) * nn)) == NULL)
|
||||
if ((names = OPENSSL_malloc_array(nn, sizeof(char *))) == NULL)
|
||||
goto end;
|
||||
parse_ext_names(tmp_ext_names, names);
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ int FuzzerInitialize(int *argc, char ***argv)
|
|||
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
|
||||
ERR_clear_error();
|
||||
prediction_table = OPENSSL_zalloc(sizeof(FUZZER_VALUE) * 65537);
|
||||
prediction_table = OPENSSL_calloc(65537, sizeof(FUZZER_VALUE));
|
||||
if (prediction_table == NULL)
|
||||
return -1;
|
||||
fuzzer_table = ossl_ht_new(&fuzz_conf);
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ static OSSL_PARAM *fuzz_params(OSSL_PARAM *param, const uint8_t **buf, size_t *l
|
|||
for (p = param; p != NULL && p->key != NULL; p++)
|
||||
p_num++;
|
||||
|
||||
fuzzed_parameters = OPENSSL_zalloc(sizeof(OSSL_PARAM) *(p_num + 1));
|
||||
fuzzed_parameters = OPENSSL_calloc(p_num + 1, sizeof(OSSL_PARAM));
|
||||
p = fuzzed_parameters;
|
||||
|
||||
for (; param != NULL && param->key != NULL; param++) {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ ossl_ml_common_pkcs8_fmt_order(const char *algorithm_name,
|
|||
const char *sep = "\t ,";
|
||||
|
||||
/* Reserve an extra terminal slot with fmt == NULL */
|
||||
if ((ret = OPENSSL_zalloc((NUM_PKCS8_FORMATS + 1) * sizeof(*ret))) == NULL)
|
||||
if ((ret = OPENSSL_calloc(NUM_PKCS8_FORMATS + 1, sizeof(*ret))) == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Entries that match a format will get a non-zero preference. */
|
||||
|
|
|
|||
|
|
@ -569,8 +569,8 @@ static int fill_mem_blocks_mt(KDF_ARGON2 *ctx)
|
|||
void **t;
|
||||
ARGON2_THREAD_DATA *t_data;
|
||||
|
||||
t = OPENSSL_zalloc(sizeof(void *)*ctx->lanes);
|
||||
t_data = OPENSSL_zalloc(ctx->lanes * sizeof(ARGON2_THREAD_DATA));
|
||||
t = OPENSSL_calloc(ctx->lanes, sizeof(void *));
|
||||
t_data = OPENSSL_calloc(ctx->lanes, sizeof(ARGON2_THREAD_DATA));
|
||||
|
||||
if (t == NULL || t_data == NULL)
|
||||
goto fail;
|
||||
|
|
@ -738,11 +738,9 @@ static int initialize(KDF_ARGON2 *ctx)
|
|||
return 0;
|
||||
|
||||
if (ctx->type != ARGON2_D)
|
||||
ctx->memory = OPENSSL_secure_zalloc(ctx->memory_blocks *
|
||||
sizeof(BLOCK));
|
||||
ctx->memory = OPENSSL_secure_calloc(ctx->memory_blocks, sizeof(BLOCK));
|
||||
else
|
||||
ctx->memory = OPENSSL_zalloc(ctx->memory_blocks *
|
||||
sizeof(BLOCK));
|
||||
ctx->memory = OPENSSL_calloc(ctx->memory_blocks, sizeof(BLOCK));
|
||||
|
||||
if (ctx->memory == NULL) {
|
||||
ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_MEMORY_SIZE,
|
||||
|
|
|
|||
Loading…
Reference in New Issue