Skip to content

Commit af66f4a

Browse files
committed
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() 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.
1 parent 456fac4 commit af66f4a

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

src/internal.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3046,14 +3046,17 @@ static int GetInputText(WOLFSSH* ssh, byte** pEol)
30463046
in = ReceiveData(ssh,
30473047
ssh->inputBuffer.buffer + ssh->inputBuffer.length, inSz);
30483048

3049-
if (in == -1)
3049+
if (in == -1) {
30503050
return WS_SOCKET_ERROR_E;
3051+
}
30513052

3052-
if (in == WS_WANT_READ)
3053+
if (in == WS_WANT_READ) {
30533054
return WS_WANT_READ;
3055+
}
30543056

3055-
if (in > inSz)
3057+
if (in > inSz) {
30563058
return WS_RECV_OVERFLOW_E;
3059+
}
30573060

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

3080-
return (gotLine ? WS_SUCCESS : WS_VERSION_E);
3083+
if (!gotLine) {
3084+
return WS_VERSION_E;
3085+
}
3086+
3087+
return WS_SUCCESS;
30813088
}
30823089

30833090

@@ -3191,7 +3198,7 @@ static int GetInputData(WOLFSSH* ssh, word32 size)
31913198
}
31923199
else {
31933200
/* all other unexpected negative values is a failure case */
3194-
ssh->error = WS_FATAL_ERROR;
3201+
ssh->error = WS_SOCKET_ERROR_E;
31953202
return WS_FATAL_ERROR;
31963203
}
31973204

@@ -3852,7 +3859,7 @@ static int DoKexInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
38523859
word32 listSz;
38533860
word32 cannedListSz;
38543861
word32 cannedAlgoNamesSz;
3855-
word32 skipSz;
3862+
word32 skipSz = 0;
38563863
word32 begin;
38573864

38583865
WLOG(WS_LOG_DEBUG, "Entering DoKexInit()");

0 commit comments

Comments
 (0)