Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ejohnstown committed Aug 16, 2024
1 parent 456fac4 commit bec7d49
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}


Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down Expand Up @@ -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()");
Expand Down

0 comments on commit bec7d49

Please sign in to comment.