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() add braces around the error check if clauses, and
   give the version error its own check instead of a ternary return.
3. In GetInputData(), if the recv return was anything else, return a
   general socket error.
  • Loading branch information
ejohnstown committed Aug 16, 2024
1 parent 456fac4 commit af66f4a
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3046,14 +3046,17 @@ static int GetInputText(WOLFSSH* ssh, byte** pEol)
in = ReceiveData(ssh,
ssh->inputBuffer.buffer + ssh->inputBuffer.length, inSz);

if (in == -1)
if (in == -1) {
return WS_SOCKET_ERROR_E;
}

if (in == WS_WANT_READ)
if (in == WS_WANT_READ) {
return WS_WANT_READ;
}

if (in > inSz)
if (in > inSz) {
return WS_RECV_OVERFLOW_E;
}

ssh->inputBuffer.length += in;
inSz -= in;
Expand All @@ -3077,7 +3080,11 @@ static int GetInputText(WOLFSSH* ssh, byte** pEol)
if (pEol)
*pEol = (byte*)eol;

return (gotLine ? WS_SUCCESS : WS_VERSION_E);
if (!gotLine) {
return WS_VERSION_E;
}

return WS_SUCCESS;
}


Expand Down Expand Up @@ -3191,7 +3198,7 @@ static int GetInputData(WOLFSSH* ssh, word32 size)
}
else {
/* all other unexpected negative values is a failure case */
ssh->error = WS_FATAL_ERROR;
ssh->error = WS_SOCKET_ERROR_E;
return WS_FATAL_ERROR;
}

Expand Down Expand Up @@ -3852,7 +3859,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 af66f4a

Please sign in to comment.