From f53ebcad9e7e8b7ce99500f5fab632f2c45b80ee Mon Sep 17 00:00:00 2001 From: tb Date: Sat, 28 Jul 2018 15:25:23 +0000 Subject: [PATCH] Remove NULL checks before (most) libcrypto *_free() functions. From Ross L. Richardson, thanks! ok deraadt --- usr.sbin/acme-client/acctproc.c | 5 ++--- usr.sbin/acme-client/certproc.c | 8 +++----- usr.sbin/acme-client/keyproc.c | 5 ++--- usr.sbin/acme-client/revokeproc.c | 8 +++----- usr.sbin/acme-client/rsa.c | 8 +++----- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/usr.sbin/acme-client/acctproc.c b/usr.sbin/acme-client/acctproc.c index c127ef82f81..2b71fb2ec79 100644 --- a/usr.sbin/acme-client/acctproc.c +++ b/usr.sbin/acme-client/acctproc.c @@ -1,4 +1,4 @@ -/* $Id: acctproc.c,v 1.11 2017/01/24 13:32:55 jsing Exp $ */ +/* $Id: acctproc.c,v 1.12 2018/07/28 15:25:23 tb Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons * @@ -393,8 +393,7 @@ out: close(netsock); if (f != NULL) fclose(f); - if (pkey != NULL) - EVP_PKEY_free(pkey); + EVP_PKEY_free(pkey); ERR_print_errors_fp(stderr); ERR_free_strings(); return rc; diff --git a/usr.sbin/acme-client/certproc.c b/usr.sbin/acme-client/certproc.c index 1ceff194975..f2cc4e311a9 100644 --- a/usr.sbin/acme-client/certproc.c +++ b/usr.sbin/acme-client/certproc.c @@ -1,4 +1,4 @@ -/* $Id: certproc.c,v 1.10 2017/01/24 13:32:55 jsing Exp $ */ +/* $Id: certproc.c,v 1.11 2018/07/28 15:25:23 tb Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons * @@ -231,10 +231,8 @@ certproc(int netsock, int filesock) out: close(netsock); close(filesock); - if (x != NULL) - X509_free(x); - if (chainx != NULL) - X509_free(chainx); + X509_free(x); + X509_free(chainx); free(csr); free(url); free(chain); diff --git a/usr.sbin/acme-client/keyproc.c b/usr.sbin/acme-client/keyproc.c index 4f383792b21..6551a03ebcf 100644 --- a/usr.sbin/acme-client/keyproc.c +++ b/usr.sbin/acme-client/keyproc.c @@ -1,4 +1,4 @@ -/* $Id: keyproc.c,v 1.9 2017/03/26 18:41:02 deraadt Exp $ */ +/* $Id: keyproc.c,v 1.10 2018/07/28 15:25:23 tb Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons * @@ -256,8 +256,7 @@ out: X509_REQ_free(x); if (name != NULL) X509_NAME_free(name); - if (pkey != NULL) - EVP_PKEY_free(pkey); + EVP_PKEY_free(pkey); ERR_print_errors_fp(stderr); ERR_free_strings(); return (rc); diff --git a/usr.sbin/acme-client/revokeproc.c b/usr.sbin/acme-client/revokeproc.c index 4365a34ec47..273496c6c74 100644 --- a/usr.sbin/acme-client/revokeproc.c +++ b/usr.sbin/acme-client/revokeproc.c @@ -1,4 +1,4 @@ -/* $Id: revokeproc.c,v 1.13 2017/07/08 13:37:23 tb Exp $ */ +/* $Id: revokeproc.c,v 1.14 2018/07/28 15:25:23 tb Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons * @@ -335,10 +335,8 @@ out: close(fd); if (f != NULL) fclose(f); - if (x != NULL) - X509_free(x); - if (bio != NULL) - BIO_free(bio); + X509_free(x); + BIO_free(bio); free(san); free(path); free(der); diff --git a/usr.sbin/acme-client/rsa.c b/usr.sbin/acme-client/rsa.c index 35ca61c40cd..798badc7659 100644 --- a/usr.sbin/acme-client/rsa.c +++ b/usr.sbin/acme-client/rsa.c @@ -1,4 +1,4 @@ -/* $Id: rsa.c,v 1.6 2017/01/24 13:32:55 jsing Exp $ */ +/* $Id: rsa.c,v 1.7 2018/07/28 15:25:23 tb Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons * @@ -62,12 +62,10 @@ rsa_key_create(FILE *f, const char *fname) warnx("%s: PEM_write_PrivateKey", fname); err: - if (pkey != NULL) - EVP_PKEY_free(pkey); + EVP_PKEY_free(pkey); pkey = NULL; out: - if (ctx != NULL) - EVP_PKEY_CTX_free(ctx); + EVP_PKEY_CTX_free(ctx); return pkey; } -- 2.20.1