[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/4] 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@xxxxxxxxxxxxx>
---
 src/dh.c | 3 +++
 1 file changed, 3 insertions(+)

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 {
-- 
2.19.1.593.gc670b1f


References:
[PATCH 0/4] dh-gex + dh: fix a couple of leaksJon Simons <jon@xxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org