diff options
author | djm@openbsd.org <djm@openbsd.org> | 2019-01-21 09:54:11 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2019-01-21 21:47:28 +1100 |
commit | 7be8572b32a15d5c3dba897f252e2e04e991c307 (patch) | |
tree | 449782dce059d2eb8d28aaa3baeaedd876b915a2 /ssh-ecdsa.c | |
parent | 803178bd5da7e72be94ba5b4c4c196d4b542da4d (diff) |
upstream: Make sshpkt_get_bignum2() allocate the bignum it is
parsing rather than make the caller do it. Saves a lot of boilerplate code.
from markus@ ok djm@
OpenBSD-Commit-ID: 576bf784f9a240f5a1401f7005364e59aed3bce9
Diffstat (limited to 'ssh-ecdsa.c')
-rw-r--r-- | ssh-ecdsa.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/ssh-ecdsa.c b/ssh-ecdsa.c index 2f5531752..599c7199d 100644 --- a/ssh-ecdsa.c +++ b/ssh-ecdsa.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-ecdsa.c,v 1.14 2018/02/07 02:06:51 jsing Exp $ */ | 1 | /* $OpenBSD: ssh-ecdsa.c,v 1.16 2019/01/21 09:54:11 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. |
4 | * Copyright (c) 2010 Damien Miller. All rights reserved. | 4 | * Copyright (c) 2010 Damien Miller. All rights reserved. |
@@ -151,15 +151,13 @@ ssh_ecdsa_verify(const struct sshkey *key, | |||
151 | } | 151 | } |
152 | 152 | ||
153 | /* parse signature */ | 153 | /* parse signature */ |
154 | if ((sig = ECDSA_SIG_new()) == NULL || | 154 | if (sshbuf_get_bignum2(sigbuf, &sig_r) != 0 || |
155 | (sig_r = BN_new()) == NULL || | 155 | sshbuf_get_bignum2(sigbuf, &sig_s) != 0) { |
156 | (sig_s = BN_new()) == NULL) { | 156 | ret = SSH_ERR_INVALID_FORMAT; |
157 | ret = SSH_ERR_ALLOC_FAIL; | ||
158 | goto out; | 157 | goto out; |
159 | } | 158 | } |
160 | if (sshbuf_get_bignum2(sigbuf, sig_r) != 0 || | 159 | if ((sig = ECDSA_SIG_new()) == NULL) { |
161 | sshbuf_get_bignum2(sigbuf, sig_s) != 0) { | 160 | ret = SSH_ERR_ALLOC_FAIL; |
162 | ret = SSH_ERR_INVALID_FORMAT; | ||
163 | goto out; | 161 | goto out; |
164 | } | 162 | } |
165 | if (!ECDSA_SIG_set0(sig, sig_r, sig_s)) { | 163 | if (!ECDSA_SIG_set0(sig, sig_r, sig_s)) { |