summaryrefslogtreecommitdiff
path: root/sshsig.c
diff options
context:
space:
mode:
authormarkus@openbsd.org <markus@openbsd.org>2020-03-06 18:13:29 +0000
committerDamien Miller <djm@mindrot.org>2020-03-13 13:13:30 +1100
commit15be29e1e3318737b0768ca37d5b4a3fbe868ef0 (patch)
tree77ff97e2ccf17153374a863ed935a0724f2d2a94 /sshsig.c
parent6fb6f186cb62a6370fba476b6a03478a1e95c30d (diff)
upstream: sshsig: return correct error, fix null-deref; ok djm
OpenBSD-Commit-ID: 1d1af7cd538b8b23e621cf7ab84f11e7a923edcd
Diffstat (limited to 'sshsig.c')
-rw-r--r--sshsig.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sshsig.c b/sshsig.c
index e63a36e1e..77df4db86 100644
--- a/sshsig.c
+++ b/sshsig.c
@@ -209,8 +209,10 @@ sshsig_wrap_sign(struct sshkey *key, const char *hashalg,
209 goto done; 209 goto done;
210 } 210 }
211 211
212 *out = blob; 212 if (out != NULL) {
213 blob = NULL; 213 *out = blob;
214 blob = NULL;
215 }
214 r = 0; 216 r = 0;
215done: 217done:
216 free(sig); 218 free(sig);
@@ -424,7 +426,7 @@ hash_buffer(const struct sshbuf *m, const char *hashalg, struct sshbuf **bp)
424 out: 426 out:
425 sshbuf_free(b); 427 sshbuf_free(b);
426 explicit_bzero(hash, sizeof(hash)); 428 explicit_bzero(hash, sizeof(hash));
427 return 0; 429 return r;
428} 430}
429 431
430int 432int
@@ -552,7 +554,7 @@ hash_file(int fd, const char *hashalg, struct sshbuf **bp)
552 sshbuf_free(b); 554 sshbuf_free(b);
553 ssh_digest_free(ctx); 555 ssh_digest_free(ctx);
554 explicit_bzero(hash, sizeof(hash)); 556 explicit_bzero(hash, sizeof(hash));
555 return 0; 557 return r;
556} 558}
557 559
558int 560int
@@ -835,7 +837,7 @@ sshsig_check_allowed_keys(const char *path, const struct sshkey *sign_key,
835 char *line = NULL; 837 char *line = NULL;
836 size_t linesize = 0; 838 size_t linesize = 0;
837 u_long linenum = 0; 839 u_long linenum = 0;
838 int r, oerrno; 840 int r = SSH_ERR_INTERNAL_ERROR, oerrno;
839 841
840 /* Check key and principal against file */ 842 /* Check key and principal against file */
841 if ((f = fopen(path, "r")) == NULL) { 843 if ((f = fopen(path, "r")) == NULL) {