diff options
Diffstat (limited to 'sshbuf-getput-crypto.c')
-rw-r--r-- | sshbuf-getput-crypto.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/sshbuf-getput-crypto.c b/sshbuf-getput-crypto.c index a49b72ef7..3dd1e1446 100644 --- a/sshbuf-getput-crypto.c +++ b/sshbuf-getput-crypto.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sshbuf-getput-crypto.c,v 1.6 2019/01/21 09:52:25 djm Exp $ */ | 1 | /* $OpenBSD: sshbuf-getput-crypto.c,v 1.7 2019/01/21 09:54:11 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2011 Damien Miller | 3 | * Copyright (c) 2011 Damien Miller |
4 | * | 4 | * |
@@ -32,16 +32,25 @@ | |||
32 | #include "sshbuf.h" | 32 | #include "sshbuf.h" |
33 | 33 | ||
34 | int | 34 | int |
35 | sshbuf_get_bignum2(struct sshbuf *buf, BIGNUM *v) | 35 | sshbuf_get_bignum2(struct sshbuf *buf, BIGNUM **valp) |
36 | { | 36 | { |
37 | BIGNUM *v; | ||
37 | const u_char *d; | 38 | const u_char *d; |
38 | size_t len; | 39 | size_t len; |
39 | int r; | 40 | int r; |
40 | 41 | ||
42 | if (valp != NULL) | ||
43 | *valp = NULL; | ||
41 | if ((r = sshbuf_get_bignum2_bytes_direct(buf, &d, &len)) != 0) | 44 | if ((r = sshbuf_get_bignum2_bytes_direct(buf, &d, &len)) != 0) |
42 | return r; | 45 | return r; |
43 | if (v != NULL && BN_bin2bn(d, len, v) == NULL) | 46 | if (valp != NULL) { |
44 | return SSH_ERR_ALLOC_FAIL; | 47 | if ((v = BN_new()) == NULL || |
48 | BN_bin2bn(d, len, v) == NULL) { | ||
49 | BN_clear_free(v); | ||
50 | return SSH_ERR_ALLOC_FAIL; | ||
51 | } | ||
52 | *valp = v; | ||
53 | } | ||
45 | return 0; | 54 | return 0; |
46 | } | 55 | } |
47 | 56 | ||