diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2020-12-23 21:33:03 +0300 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2021-02-04 09:28:11 +0300 |
commit | d53b437f9992f974c1623e9b9b9bdf053aefbcc3 (patch) | |
tree | 12b15a5d0a6e885be5e9118c5b4542c6234039f0 /crypto/x509/x509_cmp.c | |
parent | b91a13f429570512bfee290e8ec50096b0667e45 (diff) |
Allow NULL arg to OPENSSL_sk_{dup,deep_copy} returning empty stack
This simplifies many usages
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14040)
Diffstat (limited to 'crypto/x509/x509_cmp.c')
-rw-r--r-- | crypto/x509/x509_cmp.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/crypto/x509/x509_cmp.c b/crypto/x509/x509_cmp.c index 1192527125..8e525a3815 100644 --- a/crypto/x509/x509_cmp.c +++ b/crypto/x509/x509_cmp.c @@ -531,6 +531,7 @@ int X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags) } #endif + /* * Not strictly speaking an "up_ref" as a STACK doesn't have a reference * count but it has the same effect by duping the STACK and upping the ref of @@ -538,17 +539,19 @@ int X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags) */ STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain) { - STACK_OF(X509) *ret; + STACK_OF(X509) *ret = sk_X509_dup(chain); 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); + if (!X509_up_ref(x)) goto err; } return ret; + err: while (i-- > 0) X509_free(sk_X509_value(ret, i)); |