diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2019-08-16 15:18:51 +0200 |
---|---|---|
committer | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2019-08-17 16:51:13 +0200 |
commit | 2403153c95b312e0a5a178c516335ee8dd17526c (patch) | |
tree | 6935719fc47de2f8d79dd59e100b2afd95dd2471 /crypto/x509/x509_cmp.c | |
parent | 4faaf0f46d231c70df4138ce5ac36e082990dff8 (diff) |
Fix error handling in X509_chain_up_ref
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/9614)
(cherry picked from commit cae665dfa6ccec743a7f39cf80676d7d2d787e56)
Diffstat (limited to 'crypto/x509/x509_cmp.c')
-rw-r--r-- | crypto/x509/x509_cmp.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/crypto/x509/x509_cmp.c b/crypto/x509/x509_cmp.c index 02fad0c671..c65222df69 100644 --- a/crypto/x509/x509_cmp.c +++ b/crypto/x509/x509_cmp.c @@ -450,9 +450,17 @@ STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain) STACK_OF(X509) *ret; int i; ret = sk_X509_dup(chain); + if (ret == NULL) + return NULL; for (i = 0; i < sk_X509_num(ret); i++) { X509 *x = sk_X509_value(ret, i); - X509_up_ref(x); + if (!X509_up_ref(x)) + goto err; } return ret; + err: + while (i-- > 0) + X509_free (sk_X509_value(ret, i)); + sk_X509_free(ret); + return NULL; } |