From 256005ed974c25e4d6d2852b8b4d4d753240e3e6 Mon Sep 17 00:00:00 2001 From: schwarze Date: Wed, 10 Nov 2021 09:19:25 +0000 Subject: [PATCH] Sync some code style improvements from the OpenSSL 1.1.1 branch, which is still under a free license. No functional change. - No need to #include here. - return is not a function. - Do not use the pointless macro BIO_s_file_internal(). - No need to check for NULL before X509_CRL_free(3). This includes parts of the following OpenSSL commits from the 2015 to 2017 timeframe: 222561fe, 9982cbbb, f32b0abe, 26a7d938 OK tb@ --- lib/libcrypto/x509/by_file.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/libcrypto/x509/by_file.c b/lib/libcrypto/x509/by_file.c index db66617d2b9..a5a4342e884 100644 --- a/lib/libcrypto/x509/by_file.c +++ b/lib/libcrypto/x509/by_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: by_file.c,v 1.23 2021/11/10 09:00:21 schwarze Exp $ */ +/* $OpenBSD: by_file.c,v 1.24 2021/11/10 09:19:25 schwarze Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -64,7 +64,6 @@ #include #include #include -#include #include #include "x509_lcl.h" @@ -88,7 +87,7 @@ static X509_LOOKUP_METHOD x509_file_lookup = { X509_LOOKUP_METHOD * X509_LOOKUP_file(void) { - return (&x509_file_lookup); + return &x509_file_lookup; } static int @@ -116,7 +115,7 @@ by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl, } break; } - return (ok); + return ok; } int @@ -127,7 +126,7 @@ X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type) int i, count = 0; X509 *x = NULL; - in = BIO_new(BIO_s_file_internal()); + in = BIO_new(BIO_s_file()); if ((in == NULL) || (BIO_read_filename(in, file) <= 0)) { X509error(ERR_R_SYS_LIB); @@ -172,7 +171,7 @@ X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type) err: X509_free(x); BIO_free(in); - return (ret); + return ret; } int @@ -183,7 +182,7 @@ X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type) int i, count = 0; X509_CRL *x = NULL; - in = BIO_new(BIO_s_file_internal()); + in = BIO_new(BIO_s_file()); if ((in == NULL) || (BIO_read_filename(in, file) <= 0)) { X509error(ERR_R_SYS_LIB); @@ -226,10 +225,9 @@ X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type) goto err; } err: - if (x != NULL) - X509_CRL_free(x); + X509_CRL_free(x); BIO_free(in); - return (ret); + return ret; } int @@ -239,6 +237,7 @@ X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type) X509_INFO *itmp; BIO *in; int i, count = 0; + if (type != X509_FILETYPE_PEM) return X509_load_cert_file(ctx, file, type); in = BIO_new_file(file, "r"); -- 2.20.1