upstream: sshsig: return correct error, fix null-deref; ok djm

OpenBSD-Commit-ID: 1d1af7cd538b8b23e621cf7ab84f11e7a923edcd
This commit is contained in:
markus@openbsd.org 2020-03-06 18:13:29 +00:00 committed by Damien Miller
parent 6fb6f186cb
commit 15be29e1e3
1 changed files with 7 additions and 5 deletions

View File

@ -209,8 +209,10 @@ sshsig_wrap_sign(struct sshkey *key, const char *hashalg,
goto done; goto done;
} }
*out = blob; if (out != NULL) {
blob = NULL; *out = blob;
blob = NULL;
}
r = 0; r = 0;
done: done:
free(sig); free(sig);
@ -424,7 +426,7 @@ hash_buffer(const struct sshbuf *m, const char *hashalg, struct sshbuf **bp)
out: out:
sshbuf_free(b); sshbuf_free(b);
explicit_bzero(hash, sizeof(hash)); explicit_bzero(hash, sizeof(hash));
return 0; return r;
} }
int int
@ -552,7 +554,7 @@ hash_file(int fd, const char *hashalg, struct sshbuf **bp)
sshbuf_free(b); sshbuf_free(b);
ssh_digest_free(ctx); ssh_digest_free(ctx);
explicit_bzero(hash, sizeof(hash)); explicit_bzero(hash, sizeof(hash));
return 0; return r;
} }
int int
@ -835,7 +837,7 @@ sshsig_check_allowed_keys(const char *path, const struct sshkey *sign_key,
char *line = NULL; char *line = NULL;
size_t linesize = 0; size_t linesize = 0;
u_long linenum = 0; u_long linenum = 0;
int r, oerrno; int r = SSH_ERR_INTERNAL_ERROR, oerrno;
/* Check key and principal against file */ /* Check key and principal against file */
if ((f = fopen(path, "r")) == NULL) { if ((f = fopen(path, "r")) == NULL) {