aboutsummaryrefslogtreecommitdiff
path: root/src/dh.c
diff options
context:
space:
mode:
authorJon Simons <jon@jonsimons.org>2019-01-29 20:25:13 -0500
committerAndreas Schneider <asn@cryptomilk.org>2019-01-30 13:22:59 +0100
commit3760e59c13c2eb0691249616d6b8e9a076b6690c (patch)
tree0b878d0540869136b9744e52c1240fae49ac3c54 /src/dh.c
parent3334443089c56f1d4a2922fe34c6204528ad9bd3 (diff)
downloadlibssh-3760e59c13c2eb0691249616d6b8e9a076b6690c.tar.gz
libssh-3760e59c13c2eb0691249616d6b8e9a076b6690c.tar.xz
libssh-3760e59c13c2eb0691249616d6b8e9a076b6690c.zip
dh: harden error handling in 'ssh_dh_init_common'
Harden the error path in 'ssh_dh_init_common' such that all potential allocations are free'd upon exit. Signed-off-by: Jon Simons <jon@jonsimons.org> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/dh.c')
-rw-r--r--src/dh.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/dh.c b/src/dh.c
index b4b988d9..c40aef5a 100644
--- a/src/dh.c
+++ b/src/dh.c
@@ -350,6 +350,9 @@ int ssh_dh_init_common(ssh_session session){
break;
}
if (crypto->x == NULL || crypto->y == NULL || crypto->k == NULL){
+ bignum_safe_free(crypto->k);
+ bignum_safe_free(crypto->y);
+ bignum_safe_free(crypto->x);
ssh_set_error_oom(session);
return SSH_ERROR;
} else {