mirror of
git://anongit.mindrot.org/openssh.git
synced 2024-12-22 10:00:14 +00:00
upstream commit
Remove NULL-checks before sshbuf_free(). ok djm@ Upstream-ID: 5ebed00ed5f9f03b119a345085e8774565466917
This commit is contained in:
parent
a4b9e0f4e4
commit
52d7078421
@ -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;
|
||||
}
|
||||
|
||||
|
14
krl.c
14
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, §)) != 0)
|
||||
goto out;
|
||||
|
14
packet.c
14
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)
|
||||
|
@ -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);
|
||||
|
14
ssh-ecdsa.c
14
ssh-ecdsa.c
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
8
sshbuf.c
8
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
|
||||
|
29
sshkey.c
29
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user