diff options
author | Pavel Kopyl <p.kopyl@samsung.com> | 2017-11-07 13:28:18 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2018-02-21 13:18:48 +0100 |
commit | abcf241114c4dc33af95288ae7f7d10916c67db0 (patch) | |
tree | 8fddfe70dc56c32dc80e2315be13daf79eb0a85e /crypto/x509v3 | |
parent | Replaced variable-time GCD with consttime inversion to avoid side-channel att... (diff) | |
download | openssl-abcf241114c4dc33af95288ae7f7d10916c67db0.tar.xz openssl-abcf241114c4dc33af95288ae7f7d10916c67db0.zip |
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/x509v3')
-rw-r--r-- | crypto/x509v3/v3_conf.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/crypto/x509v3/v3_conf.c b/crypto/x509v3/v3_conf.c index 711ff02fb0..59caa31580 100644 --- a/crypto/x509v3/v3_conf.c +++ b/crypto/x509v3/v3_conf.c @@ -313,8 +313,12 @@ int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, const char *section, return 0; if (ctx->flags == X509V3_CTX_REPLACE) delete_ext(*sk, ext); - if (sk) - X509v3_add_ext(sk, ext, -1); + if (sk != NULL) { + if (X509v3_add_ext(sk, ext, -1) == NULL) { + X509_EXTENSION_free(ext); + return 0; + } + } X509_EXTENSION_free(ext); } return 1; |