/*
- * Copyright 2015-2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2015-2022 The OpenSSL Project Authors. All Rights Reserved.
*
- * Licensed under the OpenSSL license (the "License"). You may not use
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
static X509_CRL *CRL_from_strings(const char **pem)
{
+ X509_CRL *crl;
char *p;
BIO *b = glue2bio(pem, &p);
- X509_CRL *crl = PEM_read_bio_X509_CRL(b, NULL, NULL, NULL);
+
+ if (b == NULL) {
+ OPENSSL_free(p);
+ return NULL;
+ }
+
+ crl = PEM_read_bio_X509_CRL(b, NULL, NULL, NULL);
OPENSSL_free(p);
BIO_free(b);
*/
static X509 *X509_from_strings(const char **pem)
{
+ X509 *x;
char *p;
BIO *b = glue2bio(pem, &p);
- X509 *x = PEM_read_bio_X509(b, NULL, NULL, NULL);
+
+ if (b == NULL) {
+ OPENSSL_free(p);
+ return NULL;
+ }
+
+ x = PEM_read_bio_X509(b, NULL, NULL, NULL);
OPENSSL_free(p);
BIO_free(b);
status = X509_verify_cert(ctx) == 1 ? X509_V_OK
: X509_STORE_CTX_get_error(ctx);
err:
- sk_X509_pop_free(roots, X509_free);
+ OSSL_STACK_OF_X509_free(roots);
sk_X509_CRL_pop_free(crls, X509_CRL_free);
X509_VERIFY_PARAM_free(param);
X509_STORE_CTX_free(ctx);
return r;
}
+static int test_reuse_crl(void)
+{
+ X509_CRL *reused_crl = CRL_from_strings(kBasicCRL);
+ char *p;
+ BIO *b = glue2bio(kRevokedCRL, &p);
+
+ if (b == NULL) {
+ OPENSSL_free(p);
+ X509_CRL_free(reused_crl);
+ return 0;
+ }
+
+ reused_crl = PEM_read_bio_X509_CRL(b, &reused_crl, NULL, NULL);
+
+ OPENSSL_free(p);
+ BIO_free(b);
+ X509_CRL_free(reused_crl);
+ return 1;
+}
+
int setup_tests(void)
{
if (!TEST_ptr(test_root = X509_from_strings(kCRLTestRoot))
ADD_TEST(test_bad_issuer_crl);
ADD_TEST(test_known_critical_crl);
ADD_ALL_TESTS(test_unknown_critical_crl, OSSL_NELEM(unknown_critical_crls));
+ ADD_TEST(test_reuse_crl);
return 1;
}