summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ex_data.c
diff options
context:
space:
mode:
authorderaadt <>2014-05-29 21:07:43 +0000
committerderaadt <>2014-05-29 21:07:43 +0000
commit642d45ae22413aa8195b105d051ca8896e782c5d (patch)
treed5fe0c330801f3e72c7b588264c6027636db4330 /src/lib/libcrypto/ex_data.c
parentf60b3b3365842d8869513a7e36981671cd726939 (diff)
downloadopenbsd-642d45ae22413aa8195b105d051ca8896e782c5d.tar.gz
openbsd-642d45ae22413aa8195b105d051ca8896e782c5d.tar.bz2
openbsd-642d45ae22413aa8195b105d051ca8896e782c5d.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/ex_data.c')
-rw-r--r--src/lib/libcrypto/ex_data.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/libcrypto/ex_data.c b/src/lib/libcrypto/ex_data.c
index d8d25d320e..5cd01c72d1 100644
--- a/src/lib/libcrypto/ex_data.c
+++ b/src/lib/libcrypto/ex_data.c
@@ -424,7 +424,7 @@ int_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
424 CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA); 424 CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);
425 mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth); 425 mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);
426 if (mx > 0) { 426 if (mx > 0) {
427 storage = malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS*)); 427 storage = reallocarray(NULL, mx, sizeof(CRYPTO_EX_DATA_FUNCS*));
428 if (!storage) 428 if (!storage)
429 goto skip; 429 goto skip;
430 for (i = 0; i < mx; i++) 430 for (i = 0; i < mx; i++)
@@ -468,7 +468,7 @@ int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from)
468 if (j < mx) 468 if (j < mx)
469 mx = j; 469 mx = j;
470 if (mx > 0) { 470 if (mx > 0) {
471 storage = malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS*)); 471 storage = reallocarray(NULL, mx, sizeof(CRYPTO_EX_DATA_FUNCS*));
472 if (!storage) 472 if (!storage)
473 goto skip; 473 goto skip;
474 for (i = 0; i < mx; i++) 474 for (i = 0; i < mx; i++)
@@ -505,7 +505,7 @@ int_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
505 CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA); 505 CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);
506 mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth); 506 mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);
507 if (mx > 0) { 507 if (mx > 0) {
508 storage = malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS*)); 508 storage = reallocarray(NULL, mx, sizeof(CRYPTO_EX_DATA_FUNCS*));
509 if (!storage) 509 if (!storage)
510 goto skip; 510 goto skip;
511 for (i = 0; i < mx; i++) 511 for (i = 0; i < mx; i++)