summaryrefslogtreecommitdiffstats
path: root/crypto/x509/x509_v3.c
diff options
context:
space:
mode:
authorPavel Kopyl <p.kopyl@samsung.com>2017-11-07 15:28:18 +0300
committerMatt Caswell <matt@openssl.org>2018-02-21 12:22:56 +0000
commit2d4def005263614d23b9dcbf98f48c145ea1b0cf (patch)
tree6473f14239c7354df2c1d2855a9bc48a16326b2f /crypto/x509/x509_v3.c
parent5a19f9ea7a27453d67c09160a8c806e644e844e7 (diff)
X509V3_EXT_add_nconf_sk, X509v3_add_ext: fix errors handling
X509v3_add_ext: free 'sk' if the memory pointed to by it was malloc-ed inside this function. X509V3_EXT_add_nconf_sk: return an error if X509v3_add_ext() fails. This prevents use of a freed memory in do_body:sk_X509_EXTENSION_num(). Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4698)
Diffstat (limited to 'crypto/x509/x509_v3.c')
-rw-r--r--crypto/x509/x509_v3.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/crypto/x509/x509_v3.c b/crypto/x509/x509_v3.c
index 213e762f98..cbadd9be6f 100644
--- a/crypto/x509/x509_v3.c
+++ b/crypto/x509/x509_v3.c
@@ -128,7 +128,8 @@ STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,
X509err(X509_F_X509V3_ADD_EXT, ERR_R_MALLOC_FAILURE);
err2:
X509_EXTENSION_free(new_ex);
- sk_X509_EXTENSION_free(sk);
+ if (x != NULL && *x == NULL)
+ sk_X509_EXTENSION_free(sk);
return (NULL);
}