forked from PowerShell/openssh-portable
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upstream: change explicit_bzero();free() to freezero()
While freezero() returns early if the pointer is NULL the tests for NULL in callers are left to avoid warnings about passing an uninitialised size argument across a function boundry. ok deraadt@ djm@ OpenBSD-Commit-ID: 2660fa334fcc7cd05ec74dd99cb036f9ade6384a
- Loading branch information
1 parent
9e3220b
commit d5ba1c0
Showing
23 changed files
with
86 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: auth-options.c,v 1.90 2019/11/25 00:54:23 djm Exp $ */ | ||
/* $OpenBSD: auth-options.c,v 1.91 2020/02/26 13:40:09 jsg Exp $ */ | ||
/* | ||
* Copyright (c) 2018 Damien Miller <[email protected]> | ||
* | ||
|
@@ -222,8 +222,7 @@ sshauthopt_free(struct sshauthopt *opts) | |
free(opts->permitlisten[i]); | ||
free(opts->permitlisten); | ||
|
||
explicit_bzero(opts, sizeof(*opts)); | ||
free(opts); | ||
freezero(opts, sizeof(*opts)); | ||
} | ||
|
||
struct sshauthopt * | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: authfd.c,v 1.121 2019/12/21 02:19:13 djm Exp $ */ | ||
/* $OpenBSD: authfd.c,v 1.122 2020/02/26 13:40:09 jsg Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -561,10 +561,8 @@ ssh_remove_identity(int sock, struct sshkey *key) | |
goto out; | ||
r = decode_reply(type); | ||
out: | ||
if (blob != NULL) { | ||
explicit_bzero(blob, blen); | ||
free(blob); | ||
} | ||
if (blob != NULL) | ||
freezero(blob, blen); | ||
sshbuf_free(msg); | ||
return r; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: channels.c,v 1.395 2020/01/25 06:40:20 djm Exp $ */ | ||
/* $OpenBSD: channels.c,v 1.396 2020/02/26 13:40:09 jsg Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -625,14 +625,12 @@ channel_free(struct ssh *ssh, Channel *c) | |
if (cc->abandon_cb != NULL) | ||
cc->abandon_cb(ssh, c, cc->ctx); | ||
TAILQ_REMOVE(&c->status_confirms, cc, entry); | ||
explicit_bzero(cc, sizeof(*cc)); | ||
free(cc); | ||
freezero(cc, sizeof(*cc)); | ||
} | ||
if (c->filter_cleanup != NULL && c->filter_ctx != NULL) | ||
c->filter_cleanup(ssh, c->self, c->filter_ctx); | ||
sc->channels[c->self] = NULL; | ||
explicit_bzero(c, sizeof(*c)); | ||
free(c); | ||
freezero(c, sizeof(*c)); | ||
} | ||
|
||
void | ||
|
@@ -3295,8 +3293,7 @@ channel_input_status_confirm(int type, u_int32_t seq, struct ssh *ssh) | |
return 0; | ||
cc->cb(ssh, type, c, cc->ctx); | ||
TAILQ_REMOVE(&c->status_confirms, cc, entry); | ||
explicit_bzero(cc, sizeof(*cc)); | ||
free(cc); | ||
freezero(cc, sizeof(*cc)); | ||
return 0; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: cipher.c,v 1.114 2020/01/23 10:24:29 dtucker Exp $ */ | ||
/* $OpenBSD: cipher.c,v 1.115 2020/02/26 13:40:09 jsg Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -328,8 +328,7 @@ cipher_init(struct sshcipher_ctx **ccp, const struct sshcipher *cipher, | |
#ifdef WITH_OPENSSL | ||
EVP_CIPHER_CTX_free(cc->evp); | ||
#endif /* WITH_OPENSSL */ | ||
explicit_bzero(cc, sizeof(*cc)); | ||
free(cc); | ||
freezero(cc, sizeof(*cc)); | ||
} | ||
} | ||
return ret; | ||
|
@@ -434,8 +433,7 @@ cipher_free(struct sshcipher_ctx *cc) | |
EVP_CIPHER_CTX_free(cc->evp); | ||
cc->evp = NULL; | ||
#endif | ||
explicit_bzero(cc, sizeof(*cc)); | ||
free(cc); | ||
freezero(cc, sizeof(*cc)); | ||
} | ||
|
||
/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: clientloop.c,v 1.341 2020/02/26 01:31:47 dtucker Exp $ */ | ||
/* $OpenBSD: clientloop.c,v 1.342 2020/02/26 13:40:09 jsg Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -473,8 +473,7 @@ client_global_request_reply(int type, u_int32_t seq, struct ssh *ssh) | |
gc->cb(ssh, type, seq, gc->ctx); | ||
if (--gc->ref_count <= 0) { | ||
TAILQ_REMOVE(&global_confirms, gc, entry); | ||
explicit_bzero(gc, sizeof(*gc)); | ||
free(gc); | ||
freezero(gc, sizeof(*gc)); | ||
} | ||
|
||
ssh_packet_set_alive_timeouts(ssh, 0); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: digest-libc.c,v 1.6 2017/05/08 22:57:38 djm Exp $ */ | ||
/* $OpenBSD: digest-libc.c,v 1.7 2020/02/26 13:40:09 jsg Exp $ */ | ||
/* | ||
* Copyright (c) 2013 Damien Miller <[email protected]> | ||
* Copyright (c) 2014 Markus Friedl. All rights reserved. | ||
|
@@ -230,8 +230,7 @@ ssh_digest_free(struct ssh_digest_ctx *ctx) | |
if (digest) { | ||
explicit_bzero(ctx->mdctx, digest->ctx_len); | ||
free(ctx->mdctx); | ||
explicit_bzero(ctx, sizeof(*ctx)); | ||
free(ctx); | ||
freezero(ctx, sizeof(*ctx)); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: hostfile.c,v 1.77 2020/01/25 00:21:08 djm Exp $ */ | ||
/* $OpenBSD: hostfile.c,v 1.78 2020/02/26 13:40:09 jsg Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -298,8 +298,7 @@ free_hostkeys(struct hostkeys *hostkeys) | |
explicit_bzero(hostkeys->entries + i, sizeof(*hostkeys->entries)); | ||
} | ||
free(hostkeys->entries); | ||
explicit_bzero(hostkeys, sizeof(*hostkeys)); | ||
free(hostkeys); | ||
freezero(hostkeys, sizeof(*hostkeys)); | ||
} | ||
|
||
static int | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: monitor.c,v 1.208 2020/02/06 22:30:54 naddy Exp $ */ | ||
/* $OpenBSD: monitor.c,v 1.209 2020/02/26 13:40:09 jsg Exp $ */ | ||
/* | ||
* Copyright 2002 Niels Provos <[email protected]> | ||
* Copyright 2002 Markus Friedl <[email protected]> | ||
|
@@ -893,8 +893,7 @@ mm_answer_authpassword(struct ssh *ssh, int sock, struct sshbuf *m) | |
/* Only authenticate if the context is valid */ | ||
authenticated = options.password_authentication && | ||
auth_password(ssh, passwd); | ||
explicit_bzero(passwd, plen); | ||
free(passwd); | ||
freezero(passwd, plen); | ||
|
||
sshbuf_reset(m); | ||
if ((r = sshbuf_put_u32(m, authenticated)) != 0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: ssh-add.c,v 1.153 2020/02/18 08:58:33 dtucker Exp $ */ | ||
/* $OpenBSD: ssh-add.c,v 1.154 2020/02/26 13:40:09 jsg Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -105,8 +105,7 @@ static void | |
clear_pass(void) | ||
{ | ||
if (pass) { | ||
explicit_bzero(pass, strlen(pass)); | ||
free(pass); | ||
freezero(pass, strlen(pass)); | ||
pass = NULL; | ||
} | ||
} | ||
|
@@ -521,8 +520,7 @@ lock_agent(int agent_fd, int lock) | |
fprintf(stderr, "Passwords do not match.\n"); | ||
passok = 0; | ||
} | ||
explicit_bzero(p2, strlen(p2)); | ||
free(p2); | ||
freezero(p2, strlen(p2)); | ||
} | ||
if (passok) { | ||
if ((r = ssh_lock_agent(agent_fd, lock, p1)) == 0) { | ||
|
@@ -533,8 +531,7 @@ lock_agent(int agent_fd, int lock) | |
lock ? "" : "un", ssh_err(r)); | ||
} | ||
} | ||
explicit_bzero(p1, strlen(p1)); | ||
free(p1); | ||
freezero(p1, strlen(p1)); | ||
return (ret); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: ssh-agent.c,v 1.255 2020/02/06 22:30:54 naddy Exp $ */ | ||
/* $OpenBSD: ssh-agent.c,v 1.256 2020/02/26 13:40:09 jsg Exp $ */ | ||
/* | ||
* Author: Tatu Ylonen <[email protected]> | ||
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland | ||
|
@@ -620,8 +620,7 @@ process_lock_agent(SocketEntry *e, int lock) | |
fatal("bcrypt_pbkdf"); | ||
success = 1; | ||
} | ||
explicit_bzero(passwd, pwlen); | ||
free(passwd); | ||
freezero(passwd, pwlen); | ||
send_status(e, success); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* $OpenBSD: ssh-ed25519.c,v 1.7 2016/04/21 06:08:02 djm Exp $ */ | ||
/* $OpenBSD: ssh-ed25519.c,v 1.8 2020/02/26 13:40:09 jsg Exp $ */ | ||
/* | ||
* Copyright (c) 2013 Markus Friedl <[email protected]> | ||
* | ||
|
@@ -83,10 +83,8 @@ ssh_ed25519_sign(const struct sshkey *key, u_char **sigp, size_t *lenp, | |
r = 0; | ||
out: | ||
sshbuf_free(b); | ||
if (sig != NULL) { | ||
explicit_bzero(sig, slen); | ||
free(sig); | ||
} | ||
if (sig != NULL) | ||
freezero(sig, slen); | ||
|
||
return r; | ||
} | ||
|
@@ -153,14 +151,10 @@ ssh_ed25519_verify(const struct sshkey *key, | |
/* success */ | ||
r = 0; | ||
out: | ||
if (sm != NULL) { | ||
explicit_bzero(sm, smlen); | ||
free(sm); | ||
} | ||
if (m != NULL) { | ||
explicit_bzero(m, smlen); /* NB mlen may be invalid if r != 0 */ | ||
free(m); | ||
} | ||
if (sm != NULL) | ||
freezero(sm, smlen); | ||
if (m != NULL) | ||
freezero(m, smlen); /* NB mlen may be invalid if r != 0 */ | ||
sshbuf_free(b); | ||
free(ktype); | ||
return r; | ||
|
Oops, something went wrong.