summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1
diff options
context:
space:
mode:
authorderaadt <>2014-05-29 21:07:43 +0000
committerderaadt <>2014-05-29 21:07:43 +0000
commit3d662abca6b2a7f5bc9108b036434d61fcdb6e53 (patch)
treed5fe0c330801f3e72c7b588264c6027636db4330 /src/lib/libcrypto/asn1
parentd205a2aecb99564cccfbea61c39ebe3b0ddd7fb7 (diff)
downloadopenbsd-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/asn1')
-rw-r--r--src/lib/libcrypto/asn1/a_set.c2
-rw-r--r--src/lib/libcrypto/asn1/tasn_enc.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libcrypto/asn1/a_set.c b/src/lib/libcrypto/asn1/a_set.c
index 3aeb7e54ff..8101f7722d 100644
--- a/src/lib/libcrypto/asn1/a_set.c
+++ b/src/lib/libcrypto/asn1/a_set.c
@@ -121,7 +121,7 @@ i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp, i2d_of_void *i2d,
121 121
122 pStart = p; /* Catch the beg of Setblobs*/ 122 pStart = p; /* Catch the beg of Setblobs*/
123 /* In this array we will store the SET blobs */ 123 /* In this array we will store the SET blobs */
124 rgSetBlob = malloc(sk_OPENSSL_BLOCK_num(a) * sizeof(MYBLOB)); 124 rgSetBlob = reallocarray(NULL, sk_OPENSSL_BLOCK_num(a), sizeof(MYBLOB));
125 if (rgSetBlob == NULL) { 125 if (rgSetBlob == NULL) {
126 ASN1err(ASN1_F_I2D_ASN1_SET, ERR_R_MALLOC_FAILURE); 126 ASN1err(ASN1_F_I2D_ASN1_SET, ERR_R_MALLOC_FAILURE);
127 return 0; 127 return 0;
diff --git a/src/lib/libcrypto/asn1/tasn_enc.c b/src/lib/libcrypto/asn1/tasn_enc.c
index f5fc8820f6..cfceabe5a9 100644
--- a/src/lib/libcrypto/asn1/tasn_enc.c
+++ b/src/lib/libcrypto/asn1/tasn_enc.c
@@ -435,7 +435,7 @@ asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out, int skcontlen,
435 if (sk_ASN1_VALUE_num(sk) < 2) 435 if (sk_ASN1_VALUE_num(sk) < 2)
436 do_sort = 0; 436 do_sort = 0;
437 else { 437 else {
438 derlst = malloc(sk_ASN1_VALUE_num(sk) * 438 derlst = reallocarray(NULL, sk_ASN1_VALUE_num(sk),
439 sizeof(*derlst)); 439 sizeof(*derlst));
440 tmpdat = malloc(skcontlen); 440 tmpdat = malloc(skcontlen);
441 if (!derlst || !tmpdat) { 441 if (!derlst || !tmpdat) {