From 52d7078421844b2f88329f5be3de370b0a938636 Mon Sep 17 00:00:00 2001 From: "mmcc@openbsd.org" Date: Fri, 11 Dec 2015 04:21:11 +0000 Subject: upstream commit Remove NULL-checks before sshbuf_free(). ok djm@ Upstream-ID: 5ebed00ed5f9f03b119a345085e8774565466917 --- sshkey.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'sshkey.c') diff --git a/sshkey.c b/sshkey.c index 96a4d9090..87b093e91 100644 --- a/sshkey.c +++ b/sshkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshkey.c,v 1.30 2015/12/11 02:31:47 mmcc Exp $ */ +/* $OpenBSD: sshkey.c,v 1.31 2015/12/11 04:21:12 mmcc Exp $ */ /* * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. * Copyright (c) 2008 Alexander von Gernler. All rights reserved. @@ -420,12 +420,9 @@ cert_free(struct sshkey_cert *cert) if (cert == NULL) return; - if (cert->certblob != NULL) - sshbuf_free(cert->certblob); - if (cert->critical != NULL) - sshbuf_free(cert->critical); - if (cert->extensions != NULL) - sshbuf_free(cert->extensions); + sshbuf_free(cert->certblob); + sshbuf_free(cert->critical); + sshbuf_free(cert->extensions); free(cert->key_id); for (i = 0; i < cert->nprincipals; i++) free(cert->principals[i]); @@ -2472,8 +2469,7 @@ sshkey_certify(struct sshkey *k, struct sshkey *ca) sshbuf_reset(cert); free(sig_blob); free(ca_blob); - if (principals != NULL) - sshbuf_free(principals); + sshbuf_free(principals); return ret; } @@ -3487,10 +3483,8 @@ sshkey_private_rsa1_to_blob(struct sshkey *key, struct sshbuf *blob, out: explicit_bzero(&ciphercontext, sizeof(ciphercontext)); explicit_bzero(buf, sizeof(buf)); - if (buffer != NULL) - sshbuf_free(buffer); - if (encrypted != NULL) - sshbuf_free(encrypted); + sshbuf_free(buffer); + sshbuf_free(encrypted); return r; } @@ -3644,8 +3638,7 @@ sshkey_parse_public_rsa1_fileblob(struct sshbuf *blob, pub = NULL; out: - if (copy != NULL) - sshbuf_free(copy); + sshbuf_free(copy); sshkey_free(pub); return r; } @@ -3760,10 +3753,8 @@ sshkey_parse_private_rsa1(struct sshbuf *blob, const char *passphrase, explicit_bzero(&ciphercontext, sizeof(ciphercontext)); free(comment); sshkey_free(prv); - if (copy != NULL) - sshbuf_free(copy); - if (decrypted != NULL) - sshbuf_free(decrypted); + sshbuf_free(copy); + sshbuf_free(decrypted); return r; } #endif /* WITH_SSH1 */ -- cgit v1.2.3