diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2022-08-19 03:06:31 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2022-08-19 03:06:31 +0000 |
commit | 67b978e2a8a3c00a86e301ba0638ec14ef271b03 (patch) | |
tree | f3805860fa826cee670d0fe937fa008a0d128901 /usr.bin | |
parent | 383dba29dcbe1f0cf7a8dcb8524d15d070cc6116 (diff) |
double free() in error path; from Eusgor via GHPR333
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/sshsig.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/ssh/sshsig.c b/usr.bin/ssh/sshsig.c index 56cd59a3373..bdfb3b44442 100644 --- a/usr.bin/ssh/sshsig.c +++ b/usr.bin/ssh/sshsig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshsig.c,v 1.29 2022/03/30 04:27:51 djm Exp $ */ +/* $OpenBSD: sshsig.c,v 1.30 2022/08/19 03:06:30 djm Exp $ */ /* * Copyright (c) 2019 Google LLC * @@ -489,7 +489,7 @@ hash_file(int fd, const char *hashalg, struct sshbuf **bp) { char *hex, rbuf[8192], hash[SSH_DIGEST_MAX_LENGTH]; ssize_t n, total = 0; - struct ssh_digest_ctx *ctx; + struct ssh_digest_ctx *ctx = NULL; int alg, oerrno, r = SSH_ERR_INTERNAL_ERROR; struct sshbuf *b = NULL; @@ -512,7 +512,6 @@ hash_file(int fd, const char *hashalg, struct sshbuf **bp) continue; oerrno = errno; error_f("read: %s", strerror(errno)); - ssh_digest_free(ctx); errno = oerrno; r = SSH_ERR_SYSTEM_ERROR; goto out; @@ -547,9 +546,11 @@ hash_file(int fd, const char *hashalg, struct sshbuf **bp) /* success */ r = 0; out: + oerrno = errno; sshbuf_free(b); ssh_digest_free(ctx); explicit_bzero(hash, sizeof(hash)); + errno = oerrno; return r; } |