]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream commit
authormmcc@openbsd.org <mmcc@openbsd.org>
Fri, 11 Dec 2015 04:21:11 +0000 (04:21 +0000)
committerDamien Miller <djm@mindrot.org>
Fri, 18 Dec 2015 03:50:48 +0000 (14:50 +1100)
Remove NULL-checks before sshbuf_free().

ok djm@

Upstream-ID: 5ebed00ed5f9f03b119a345085e8774565466917

authfile.c
krl.c
packet.c
ssh-dss.c
ssh-ecdsa.c
ssh-rsa.c
sshbuf.c
sshkey.c

index 9cd490ca3525569d0ff478d8f447692a1af10783..d67042411cca652d51a0ef81858414ced647b684 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: authfile.c,v 1.119 2015/12/11 02:31:47 mmcc Exp $ */
+/* $OpenBSD: authfile.c,v 1.120 2015/12/11 04:21:11 mmcc Exp $ */
 /*
  * Copyright (c) 2000, 2013 Markus Friedl.  All rights reserved.
  *
@@ -243,8 +243,7 @@ sshkey_load_private_type_fd(int fd, int type, const char *passphrase,
        /* success */
        r = 0;
  out:
-       if (buffer != NULL)
-               sshbuf_free(buffer);
+       sshbuf_free(buffer);
        return r;
 }
 
@@ -278,8 +277,7 @@ sshkey_load_private(const char *filename, const char *passphrase,
        r = 0;
  out:
        close(fd);
-       if (buffer != NULL)
-               sshbuf_free(buffer);
+       sshbuf_free(buffer);
        return r;
 }
 
diff --git a/krl.c b/krl.c
index 0194f1c72be23faf874f7088fb82469415106b0b..ec3b82bea66d8c72038da6b6dce79410c376f768 100644 (file)
--- a/krl.c
+++ b/krl.c
@@ -14,7 +14,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $OpenBSD: krl.c,v 1.35 2015/12/04 16:41:28 markus Exp $ */
+/* $OpenBSD: krl.c,v 1.36 2015/12/11 04:21:12 mmcc Exp $ */
 
 #include "includes.h"
 
@@ -826,10 +826,8 @@ parse_revoked_certs(struct sshbuf *buf, struct ssh_krl *krl)
                goto out;
 
        while (sshbuf_len(buf) > 0) {
-               if (subsect != NULL) {
-                       sshbuf_free(subsect);
-                       subsect = NULL;
-               }
+               sshbuf_free(subsect);
+               subsect = NULL;
                if ((r = sshbuf_get_u8(buf, &type)) != 0 ||
                    (r = sshbuf_froms(buf, &subsect)) != 0)
                        goto out;
@@ -1059,10 +1057,8 @@ ssh_krl_from_blob(struct sshbuf *buf, struct ssh_krl **krlp,
        if ((r = sshbuf_consume(copy, sects_off)) != 0)
                goto out;
        while (sshbuf_len(copy) > 0) {
-               if (sect != NULL) {
-                       sshbuf_free(sect);
-                       sect = NULL;
-               }
+               sshbuf_free(sect);
+               sect = NULL;
                if ((r = sshbuf_get_u8(copy, &type)) != 0 ||
                    (r = sshbuf_froms(copy, &sect)) != 0)
                        goto out;
index 8d9bcd8db52e2cff00af8a3efc72ef586e06c07f..27e85e3a111a2596c41769ade5a7bfe974df9c18 100644 (file)
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.220 2015/12/11 03:24:25 djm Exp $ */
+/* $OpenBSD: packet.c,v 1.221 2015/12/11 04:21:12 mmcc Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -2453,8 +2453,7 @@ newkeys_to_blob(struct sshbuf *m, struct ssh *ssh, int mode)
                goto out;
        r = sshbuf_put_stringb(m, b);
  out:
-       if (b != NULL)
-               sshbuf_free(b);
+       sshbuf_free(b);
        return r;
 }
 
@@ -2590,8 +2589,7 @@ newkeys_from_blob(struct sshbuf *m, struct ssh *ssh, int mode)
        r = 0;
  out:
        free(newkey);
-       if (b != NULL)
-               sshbuf_free(b);
+       sshbuf_free(b);
        return r;
 }
 
@@ -2624,10 +2622,8 @@ kex_from_blob(struct sshbuf *m, struct kex **kexp)
  out:
        if (r != 0 || kexp == NULL) {
                if (kex != NULL) {
-                       if (kex->my != NULL)
-                               sshbuf_free(kex->my);
-                       if (kex->peer != NULL)
-                               sshbuf_free(kex->peer);
+                       sshbuf_free(kex->my);
+                       sshbuf_free(kex->peer);
                        free(kex);
                }
                if (kexp != NULL)
index 254f2a39b262da1d86cc2ed429beb14cae405324..cc47dcf5f14f5b23e63b6cce0a47b8779d61f47b 100644 (file)
--- a/ssh-dss.c
+++ b/ssh-dss.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-dss.c,v 1.33 2015/12/10 17:08:40 mmcc Exp $ */
+/* $OpenBSD: ssh-dss.c,v 1.34 2015/12/11 04:21:12 mmcc Exp $ */
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
  *
@@ -122,8 +122,7 @@ ssh_dss_sign(const struct sshkey *key, u_char **sigp, size_t *lenp,
        explicit_bzero(digest, sizeof(digest));
        if (sig != NULL)
                DSA_SIG_free(sig);
-       if (b != NULL)
-               sshbuf_free(b);
+       sshbuf_free(b);
        return ret;
 }
 
@@ -209,8 +208,7 @@ ssh_dss_verify(const struct sshkey *key,
        explicit_bzero(digest, sizeof(digest));
        if (sig != NULL)
                DSA_SIG_free(sig);
-       if (b != NULL)
-               sshbuf_free(b);
+       sshbuf_free(b);
        free(ktype);
        if (sigblob != NULL) {
                explicit_bzero(sigblob, len);
index 2c76f8b43793b038456f125c0f38c90d5d96d69b..74912dfd906c02cf8b3a6dd99b4f73fa364178df 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-ecdsa.c,v 1.11 2014/06/24 01:13:21 djm Exp $ */
+/* $OpenBSD: ssh-ecdsa.c,v 1.12 2015/12/11 04:21:12 mmcc Exp $ */
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
  * Copyright (c) 2010 Damien Miller.  All rights reserved.
@@ -99,10 +99,8 @@ ssh_ecdsa_sign(const struct sshkey *key, u_char **sigp, size_t *lenp,
        ret = 0;
  out:
        explicit_bzero(digest, sizeof(digest));
-       if (b != NULL)
-               sshbuf_free(b);
-       if (bb != NULL)
-               sshbuf_free(bb);
+       sshbuf_free(b);
+       sshbuf_free(bb);
        if (sig != NULL)
                ECDSA_SIG_free(sig);
        return ret;
@@ -179,10 +177,8 @@ ssh_ecdsa_verify(const struct sshkey *key,
 
  out:
        explicit_bzero(digest, sizeof(digest));
-       if (sigbuf != NULL)
-               sshbuf_free(sigbuf);
-       if (b != NULL)
-               sshbuf_free(b);
+       sshbuf_free(sigbuf);
+       sshbuf_free(b);
        if (sig != NULL)
                ECDSA_SIG_free(sig);
        free(ktype);
index 4eb00c87c2ab2cacba54a7b0f0db7c156fe59814..53d44d1f31a246aa93b64140f80b31ea7418f065 100644 (file)
--- a/ssh-rsa.c
+++ b/ssh-rsa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-rsa.c,v 1.57 2015/12/10 17:08:40 mmcc Exp $ */
+/* $OpenBSD: ssh-rsa.c,v 1.58 2015/12/11 04:21:12 mmcc Exp $ */
 /*
  * Copyright (c) 2000, 2003 Markus Friedl <markus@openbsd.org>
  *
@@ -156,8 +156,7 @@ ssh_rsa_sign(const struct sshkey *key, u_char **sigp, size_t *lenp,
                explicit_bzero(sig, slen);
                free(sig);
        }
-       if (b != NULL)
-               sshbuf_free(b);
+       sshbuf_free(b);
        return ret;
 }
 
@@ -227,8 +226,7 @@ ssh_rsa_verify(const struct sshkey *key,
                free(sigblob);
        }
        free(ktype);
-       if (b != NULL)
-               sshbuf_free(b);
+       sshbuf_free(b);
        explicit_bzero(digest, sizeof(digest));
        return ret;
 }
index fd281ed9eac9150e8565fedb64a18c15e5834364..f52b567679ae1da66c31f3895e8948ff610b8a5c 100644 (file)
--- a/sshbuf.c
+++ b/sshbuf.c
@@ -1,4 +1,4 @@
-/*     $OpenBSD: sshbuf.c,v 1.4 2015/10/05 17:11:21 djm Exp $  */
+/*     $OpenBSD: sshbuf.c,v 1.5 2015/12/11 04:21:12 mmcc Exp $ */
 /*
  * Copyright (c) 2011 Damien Miller
  *
@@ -163,10 +163,8 @@ sshbuf_free(struct sshbuf *buf)
         * If we are a child, the free our parent to decrement its reference
         * count and possibly free it.
         */
-       if (buf->parent != NULL) {
-               sshbuf_free(buf->parent);
-               buf->parent = NULL;
-       }
+       sshbuf_free(buf->parent);
+       buf->parent = NULL;
        /*
         * If we are a parent with still-extant children, then don't free just
         * yet. The last child's call to sshbuf_free should decrement our
index 96a4d90901e8a27df3d4dbd2141b2e785158a66b..87b093e91d2648811d1f37e84d397f87c64534b8 100644 (file)
--- 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 */