Import OpenSSL1.1.1k
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL licenses, (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,17 +30,16 @@ static int test_certs(int num)
|
||||
typedef int (*i2d_X509_t)(X509 *, unsigned char **);
|
||||
int err = 0;
|
||||
BIO *fp = BIO_new_file(test_get_argument(num), "r");
|
||||
X509 *reuse = NULL;
|
||||
|
||||
if (!TEST_ptr(fp))
|
||||
return 0;
|
||||
|
||||
for (c = 0; !err && PEM_read_bio(fp, &name, &header, &data, &len); ++c) {
|
||||
const int trusted = (strcmp(name, PEM_STRING_X509_TRUSTED) == 0);
|
||||
|
||||
d2i_X509_t d2i = trusted ? d2i_X509_AUX : d2i_X509;
|
||||
i2d_X509_t i2d = trusted ? i2d_X509_AUX : i2d_X509;
|
||||
X509 *cert = NULL;
|
||||
X509 *reuse = NULL;
|
||||
const unsigned char *p = data;
|
||||
unsigned char *buf = NULL;
|
||||
unsigned char *bufp;
|
||||
@@ -93,9 +92,15 @@ static int test_certs(int num)
|
||||
goto next;
|
||||
}
|
||||
p = buf;
|
||||
reuse = d2i(&reuse, &p, enclen);
|
||||
if (reuse == NULL || X509_cmp (reuse, cert)) {
|
||||
TEST_error("X509_cmp does not work with %s", name);
|
||||
reuse = d2i(NULL, &p, enclen);
|
||||
if (reuse == NULL) {
|
||||
TEST_error("second d2i call failed for %s", name);
|
||||
err = 1;
|
||||
goto next;
|
||||
}
|
||||
err = X509_cmp(reuse, cert);
|
||||
if (err != 0) {
|
||||
TEST_error("X509_cmp for %s resulted in %d", name, err);
|
||||
err = 1;
|
||||
goto next;
|
||||
}
|
||||
@@ -141,13 +146,13 @@ static int test_certs(int num)
|
||||
*/
|
||||
next:
|
||||
X509_free(cert);
|
||||
X509_free(reuse);
|
||||
OPENSSL_free(buf);
|
||||
OPENSSL_free(name);
|
||||
OPENSSL_free(header);
|
||||
OPENSSL_free(data);
|
||||
}
|
||||
BIO_free(fp);
|
||||
X509_free(reuse);
|
||||
|
||||
if (ERR_GET_REASON(ERR_peek_last_error()) == PEM_R_NO_START_LINE) {
|
||||
/* Reached end of PEM file */
|
||||
|
||||
Reference in New Issue
Block a user