[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/4] dh: harden error handling in 'ssh_dh_init_common'
  [Thread Prev] | [Thread Next]
 
 
- Subject: [PATCH 4/4] dh: harden error handling in 'ssh_dh_init_common'
- From: Jon Simons <jon@xxxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Tue, 29 Jan 2019 21:11:50 -0500
- To: libssh@xxxxxxxxxx
- Cc: Jon Simons <jon@xxxxxxxxxxxxx>
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
| [PATCH 0/4] dh-gex + dh: fix a couple of leaks | Jon Simons <jon@xxxxxxxxxxxxx> | 

