When looking up the channel object for the current channel ID, if the
lookup failed, we still checked if the channel had an EOF with a null
pointer. That function, does check for NULL and error, but it is better
to error out sooner.
Affected function: ReceiveScpMessage.
Move the NULL validation checks inside the existing NULL guards for
ssh and ssh->ctx. Previously, the check accessed ssh->ctx outside
the guard, causing a NULL dereference when ssh or ssh->ctx was NULL.
Also fix wolfSSH_SetTpmKey to check tpmKey instead of tpmDev.
In DoCheckUser, after calling auth->checkUserCb(usr) into rc, the
failure check on line 1063 compared ret instead of rc against
WSSHD_AUTH_FAILURE. Since ret is WOLFSSH_USERAUTH_SUCCESS at that
point, the condition was always false, causing callback failures to
fall through to the generic error branch with WOLFSSH_USERAUTH_FAILURE
instead of returning WOLFSSH_USERAUTH_INVALID_USER.
The upper-bound check in the octal-to-integer conversion loop used
modeOctet[0] instead of modeOctet[i], so only the first character
was validated against '7'. Characters at positions 1-3 could have
values above '7' without triggering an error.
WMEMCMP was comparing the computed SHA-256 digest against the
WOLFSSH_AGENT_ID struct pointer instead of the id field within
the struct, causing key lookups by digest to never match.
Fix inverted WMEMCMP check that removed non-matching entries and kept
matching ones. WMEMCMP returns 0 on match, so the condition was backwards.
Fix head-of-list removal setting idList to NULL instead of cur->next,
which dropped all remaining entries after the removed one
The while loop condition only checked that the opcode byte was in bounds
(idx < modesSz) but not the 4-byte argument read by ato32(). When
modesSz had a remainder of 1 mod 5 and the trailing byte was a valid
opcode (1-159) rather than TTY_OP_END, ato32() would read 4 bytes past
the buffer. Change the loop guard to require a full TERMINAL_MODE_SZ
bytes remaining before entering the loop body.
Change && to || in 5 instances where public key type matching used
AND instead of OR, causing WMEMCMP to be skipped when type sizes
matched. Two key types with the same size but different content
would incorrectly pass validation.
Affected functions: DoUserAuthRequestRsaCert, DoUserAuthRequestEcc,
and DoUserAuthRequestEccCert.
Simulate netowrk latency using netem and use it to test the non-blocking
mode of SFTP. This helps find issues which would affect running an SFTP
server on a microcontroller. It helped find the bug fixed in #876.
1. Update caching the download of the FatFS source archive to the
pattern other tests are using to cache items. It was downloading
the FatFS source archive every time, despite it being in the cache.
2. Update building wolfSSL to follow the pattern of the other tests.
When wolfSSH_SFTP_buffer_send() called wolfSSH_stream_send(), the data
would be consumed into the SSH output buffer even if the underlying
socket returned EWOULDBLOCK/EAGAIN. SendChannelData() returns the
positive dataSz on WS_WANT_WRITE, causing the SFTP layer to advance
its buffer index as if the data was sent. The SSH output buffer still
had pending data that was never flushed, leading to an indefinite hang.
Fix: At the start of wolfSSH_SFTP_buffer_send(), check if there's
pending data in ssh->outputBuffer from a previous WS_WANT_WRITE. If
so, attempt to flush it first and return WS_WANT_WRITE if the flush
fails. This ensures the caller retries until all pending data is sent.
Also expose WS_SFTP_BUFFER and wolfSSH_SFTP_buffer_send() as
WOLFSSH_LOCAL for unit testing, and add regression test that verifies
the fix catches the bug.
Fixes ZD 21157
1. The individual bytes of the value read by ato32() are promoted to
int values. Added typecasts to word32 for each of the bytes of the
32-bit value so they are treated as unsigned values like the target
type. Also shifted each byte separately after masking them and then
oring them into a temp.
2. To get the e value from the KexDhInit message, use the
GetStringRef() function.
3. Add bounds checking of eSz.
Fixes CID: 572837
1. Reorganize the KEX test to allow for testing any KEX algorithm. Add test
cases for the new algorithms to the KEX test.
2. Reorder the cannedKexAlgoNames with the ML-KEM algos first.
3. Add the new algos to wolfSSH_GetText().
4. Add comments and whitespace cleanup.
When running the build tests, the terminal size gets set to 0x0. When
then tests finish, things like vim start to misbehave until you change
your term window size.
1. Echoserver will not change the terminal size when in echo mode.
2. Do not update the modes when the echo server is not in echo mode.
3. Do not set the terminal update callback context when the echo server
is not in echo mode.
4. Update the guards around the above three items to match the guards for
the modes update function.
1. When looking up a name in the name-ID map, don't bother checking if
the name is NULL.
2. The GetString functions should fail if the destination string
parameter is NULL.
3. The GetString functions should not bother to copy an empty string
found in the data stream.
4. When checking the public key type provided by the callback, do not
check it when it is NULL.
1. Modify GetStringAlloc() to also take the string length as provided by
GetUint32().
2. New use of GetStringAlloc() was misusing the heap. Fix using the
updated GetStringAlloc() function.
3. For a pty-req, directly update the heights, widths, and mode.