Skip to content

Commit bec7d49

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() and GetInputData(), set the error value into ssh->error and just return WS_ERROR.
1 parent 456fac4 commit bec7d49

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

Diff for: src/internal.c

+23-12
Original file line numberDiff line numberDiff line change
@@ -3046,14 +3046,20 @@ static int GetInputText(WOLFSSH* ssh, byte** pEol)
30463046
in = ReceiveData(ssh,
30473047
ssh->inputBuffer.buffer + ssh->inputBuffer.length, inSz);
30483048

3049-
if (in == -1)
3050-
return WS_SOCKET_ERROR_E;
3049+
if (in == -1) {
3050+
ssh->error = WS_SOCKET_ERROR_E;
3051+
return WS_ERROR;
3052+
}
30513053

3052-
if (in == WS_WANT_READ)
3053-
return WS_WANT_READ;
3054+
if (in == WS_WANT_READ) {
3055+
ssh->error = WS_WANT_READ;
3056+
return WS_ERROR;
3057+
}
30543058

3055-
if (in > inSz)
3056-
return WS_RECV_OVERFLOW_E;
3059+
if (in > inSz) {
3060+
ssh->error = WS_RECV_OVERFLOW_E;
3061+
return WS_ERROR;
3062+
}
30573063

30583064
ssh->inputBuffer.length += in;
30593065
inSz -= in;
@@ -3077,7 +3083,12 @@ static int GetInputText(WOLFSSH* ssh, byte** pEol)
30773083
if (pEol)
30783084
*pEol = (byte*)eol;
30793085

3080-
return (gotLine ? WS_SUCCESS : WS_VERSION_E);
3086+
if (!gotLine) {
3087+
ssh->error = WS_VERSION_E;
3088+
return WS_ERROR;
3089+
}
3090+
3091+
return WS_SUCCESS;
30813092
}
30823093

30833094

@@ -3177,12 +3188,12 @@ static int GetInputData(WOLFSSH* ssh, word32 size)
31773188
size);
31783189
if (in == -1) {
31793190
ssh->error = WS_SOCKET_ERROR_E;
3180-
return WS_FATAL_ERROR;
3191+
return WS_ERROR;
31813192
}
31823193

31833194
if (in == WS_WANT_READ) {
31843195
ssh->error = WS_WANT_READ;
3185-
return WS_FATAL_ERROR;
3196+
return WS_ERROR;
31863197
}
31873198

31883199
if (in >= 0) {
@@ -3191,8 +3202,8 @@ static int GetInputData(WOLFSSH* ssh, word32 size)
31913202
}
31923203
else {
31933204
/* all other unexpected negative values is a failure case */
3194-
ssh->error = WS_FATAL_ERROR;
3195-
return WS_FATAL_ERROR;
3205+
ssh->error = WS_SOCKET_ERROR_E;
3206+
return WS_ERROR;
31963207
}
31973208

31983209
} while (size);
@@ -3852,7 +3863,7 @@ static int DoKexInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
38523863
word32 listSz;
38533864
word32 cannedListSz;
38543865
word32 cannedAlgoNamesSz;
3855-
word32 skipSz;
3866+
word32 skipSz = 0;
38563867
word32 begin;
38573868

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

0 commit comments

Comments
 (0)