From 228c3d9f4809797b11d260d521feed172950927b Mon Sep 17 00:00:00 2001 From: Will Cosgrove Date: Mon, 12 Mar 2018 10:22:52 -0700 Subject: [PATCH] Added basic bounds checking #206 Basic bounds checking in ecdh_sha2_nistp() --- src/kex.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/kex.c b/src/kex.c index b034480e..c79bd717 100644 --- a/src/kex.c +++ b/src/kex.c @@ -1928,7 +1928,13 @@ static int ecdh_sha2_nistp(LIBSSH2_SESSION *session, libssh2_curve_type type, { int ret = 0; int rc; - + + if(data_len < 5){ + ret = _libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_INIT, + "Host key data is too short"); + return ret; + } + if(exchange_state->state == libssh2_NB_state_idle) { /* Setup initial values */