aboutsummaryrefslogtreecommitdiff
path: root/crypto/asn1/a_dup.c
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2021-04-12 13:58:14 +1000
committerShane Lontis <shane.lontis@oracle.com>2021-04-16 12:10:08 +1000
commit42e7d2f10e3658c0c248df8a6edf3c48c477e4b0 (patch)
tree1122340c23e67327e2673fd516c5be2dc666e228 /crypto/asn1/a_dup.c
parent34ed73339602c361d09fe4233d65cef996356239 (diff)
downloadopenssl-42e7d2f10e3658c0c248df8a6edf3c48c477e4b0.zip
openssl-42e7d2f10e3658c0c248df8a6edf3c48c477e4b0.tar.gz
openssl-42e7d2f10e3658c0c248df8a6edf3c48c477e4b0.tar.bz2
Add more negative checks for integers passed to OPENSSL_malloc().
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14830)
Diffstat (limited to 'crypto/asn1/a_dup.c')
-rw-r--r--crypto/asn1/a_dup.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/asn1/a_dup.c b/crypto/asn1/a_dup.c
index bdefa44..263c8a0 100644
--- a/crypto/asn1/a_dup.c
+++ b/crypto/asn1/a_dup.c
@@ -24,6 +24,9 @@ void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, const void *x)
return NULL;
i = i2d(x, NULL);
+ if (i <= 0)
+ return NULL;
+
b = OPENSSL_malloc(i + 10);
if (b == NULL) {
ERR_raise(ERR_LIB_ASN1, ERR_R_MALLOC_FAILURE);