From bec7d49ffd87deac3ea19aa89df4523688be7861 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Fri, 16 Aug 2024 13:58:25 -0700 Subject: [PATCH] Fixup 1. Initialize a local variable DoKexInit() as a compiler complains it is getting used with a garbage value. (Not true, but hushing the compiler.) 2. In GetInputText() and GetInputData(), set the error value into ssh->error and just return WS_ERROR. --- src/internal.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/internal.c b/src/internal.c index 99f9a4574..b7ecbe627 100644 --- a/src/internal.c +++ b/src/internal.c @@ -3046,14 +3046,20 @@ static int GetInputText(WOLFSSH* ssh, byte** pEol) in = ReceiveData(ssh, ssh->inputBuffer.buffer + ssh->inputBuffer.length, inSz); - if (in == -1) - return WS_SOCKET_ERROR_E; + if (in == -1) { + ssh->error = WS_SOCKET_ERROR_E; + return WS_ERROR; + } - if (in == WS_WANT_READ) - return WS_WANT_READ; + if (in == WS_WANT_READ) { + ssh->error = WS_WANT_READ; + return WS_ERROR; + } - if (in > inSz) - return WS_RECV_OVERFLOW_E; + if (in > inSz) { + ssh->error = WS_RECV_OVERFLOW_E; + return WS_ERROR; + } ssh->inputBuffer.length += in; inSz -= in; @@ -3077,7 +3083,12 @@ static int GetInputText(WOLFSSH* ssh, byte** pEol) if (pEol) *pEol = (byte*)eol; - return (gotLine ? WS_SUCCESS : WS_VERSION_E); + if (!gotLine) { + ssh->error = WS_VERSION_E; + return WS_ERROR; + } + + return WS_SUCCESS; } @@ -3177,12 +3188,12 @@ static int GetInputData(WOLFSSH* ssh, word32 size) size); if (in == -1) { ssh->error = WS_SOCKET_ERROR_E; - return WS_FATAL_ERROR; + return WS_ERROR; } if (in == WS_WANT_READ) { ssh->error = WS_WANT_READ; - return WS_FATAL_ERROR; + return WS_ERROR; } if (in >= 0) { @@ -3191,8 +3202,8 @@ static int GetInputData(WOLFSSH* ssh, word32 size) } else { /* all other unexpected negative values is a failure case */ - ssh->error = WS_FATAL_ERROR; - return WS_FATAL_ERROR; + ssh->error = WS_SOCKET_ERROR_E; + return WS_ERROR; } } while (size); @@ -3852,7 +3863,7 @@ static int DoKexInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx) word32 listSz; word32 cannedListSz; word32 cannedAlgoNamesSz; - word32 skipSz; + word32 skipSz = 0; word32 begin; WLOG(WS_LOG_DEBUG, "Entering DoKexInit()");