Replace the original message parsing functions with the GetStringRef()
function, which does better bounds checking.
Affected function: DoUserAuthRequestPassword.
Issue: F-411
The DoIgnore() function was not bounds checking the ignore message.
Changed it to use the GetSkip() function which does bounds checking and
skips the current blob. Updated GetSkip() to allow 0 length blobs to
skip.
Affected function: DoIgnore.
Issue: F-410
In wolfSSHd, the comparisons of the password hash and public keys were
using memcmp(). Changed to use ConstantCompare().
Affected functions: CheckPasswordHashUnix, CheckPublicKeyUnix.
Issue: F-53
1. When disabling mlkem768nistp256-sha256, there's a crash when doing a
mlkem768x25519-sha256 KEX. It tries to do a DH key exchange instead
of x25519 with ML-KEM. Modified the check.
2. Fixed a guard where the build was treating not having
mlkem768nistp256-sha256 like a FIPS build disallowing using ML-KEM
when generating sesssion keys. It shouldn't make that check.
3. Added a test case to the KEM test.
1. Adds --disable-server and --disable-client configure flags. Allows for
compile-time exclusion of server or client code.
2. Add check to internal.h for both NO_WOLFSSH_SERVER and
NO_WOLFSSH_CLIENT being set and errors.
3. In ports.h, add check for not-NO_WOLFSSH_CLIENT so SFTP/SCP
filesystrem types are also available in client-only builds.
4. Update the NO_WOLFSSH_SERVER and NO_WOLFSSH_DIR guards around
wolfsftp.c. Update wolfSSH_SFTP_free() to skip directory cleanup
when server code is disabled.
ZD #21261
Removed the variable. The flags passed to ff_open() are appropriate for
ff_open(). Just check that read or write is set.
Affected function: ff_open.
Issue: F-213
When a copy of the user's password is freed, it wasn't getting force
zeroed. It might still exist in the heap after getting freed. Added
a call to `ForceZero()`.
Affected function: CheckPasswordUnix.
Issue: F-56
Addded a break to the 'J' case of a switch statement that handles
terminal display clearing for Windows. It was flowing into case 'K'
without an explicit fallthrough tag.
Affected function: wolfSSH_DoControlSeq.
Issue: F-49
Check the return value of `wc_InitRsaKey()`. It will initialize the
structure provided the pointer is non-null. Since the key is on the
stack, the later call to `wc_FreeRsaKey()` will succeed as well.
Modified the check for the encoded signature size inside the block where
it is set; that check also updates the return value.
Affected function: SignHashRsa.
Issue: F-212
1. Call `wc_ecc_init()` on an ECC key before importing it.
2. Incidental: `PostLock()` and `PostUnlock()` needed their agent pointers
tagged as unused.
Affected functions: SignHashEcc. PostLock and PostUnlock.
Issue: F-211
1. When wolfSSH_worker() receives channel data, it should set the
channelId for the data. It was not happening. Change the check for
WS_SUCCESS to also check for WS_CHAN_RXD.
1. Add a test script and expect script for testing forwarding.
2. Update portfwd to have a ready file option.
3. Fix echoserver error string, needed NL.
1. Fix a couple unused variable warnings.
2. In wolfSSH_AGENT_DefaultActions(), fix comparison to the result of
snprintf() treating normal result as an error. Reset the return code
for the error state of the socket() command. Better cleanup of agent
startup failures.
Was using OR to check if a bit was set in the read-only file attribute.
This was always succeeding. Needed to change to an AND to see if it is
set.
Affected function: GetFileStats.
After creating a new SSH context, the pointer returned wasn't checked;
the pointer to the pointer was checked. Changed to the correct pointer.
Affected function: SetupCTX.
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