From: Peiwei Hu Date: Sun, 14 Nov 2021 16:41:21 +0000 (+0800) Subject: BIO_read_filename: fix return check X-Git-Tag: openssl-3.2.0-alpha1~3328 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3f0362407f6f40e413d6dcb35888514dbaed6f8;p=thirdparty%2Fopenssl.git BIO_read_filename: fix return check Reviewed-by: Matt Caswell Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/17033) --- diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index a9e71046b37..e77b6ec0974 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -625,7 +625,7 @@ STACK_OF(X509_NAME) *SSL_load_client_CA_file_ex(const char *file, ERR_raise(ERR_LIB_SSL, ERR_R_MALLOC_FAILURE); goto err; } - if (!BIO_read_filename(in, file)) + if (BIO_read_filename(in, file) <= 0) goto err; /* Internally lh_X509_NAME_retrieve() needs the libctx to retrieve SHA1 */ @@ -696,7 +696,7 @@ int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, goto err; } - if (!BIO_read_filename(in, file)) + if (BIO_read_filename(in, file) <= 0) goto err; for (;;) { diff --git a/test/sslapitest.c b/test/sslapitest.c index b06d5d7a149..00f27cb78e9 100644 --- a/test/sslapitest.c +++ b/test/sslapitest.c @@ -7994,7 +7994,7 @@ static int cert_cb(SSL *s, void *arg) if (!TEST_ptr(chain)) goto out; if (!TEST_ptr(in = BIO_new(BIO_s_file())) - || !TEST_int_ge(BIO_read_filename(in, rootfile), 0) + || !TEST_int_gt(BIO_read_filename(in, rootfile), 0) || !TEST_ptr(rootx = X509_new_ex(libctx, NULL)) || !TEST_ptr(PEM_read_bio_X509(in, &rootx, NULL, NULL)) || !TEST_true(sk_X509_push(chain, rootx))) @@ -8002,13 +8002,13 @@ static int cert_cb(SSL *s, void *arg) rootx = NULL; BIO_free(in); if (!TEST_ptr(in = BIO_new(BIO_s_file())) - || !TEST_int_ge(BIO_read_filename(in, ecdsacert), 0) + || !TEST_int_gt(BIO_read_filename(in, ecdsacert), 0) || !TEST_ptr(x509 = X509_new_ex(libctx, NULL)) || !TEST_ptr(PEM_read_bio_X509(in, &x509, NULL, NULL))) goto out; BIO_free(in); if (!TEST_ptr(in = BIO_new(BIO_s_file())) - || !TEST_int_ge(BIO_read_filename(in, ecdsakey), 0) + || !TEST_int_gt(BIO_read_filename(in, ecdsakey), 0) || !TEST_ptr(pkey = PEM_read_bio_PrivateKey_ex(in, NULL, NULL, NULL, libctx, NULL)))