Commit Graph

2504 Commits (bfbf0edbb979603ce165a65a0f7101467647a3f2)

Author SHA1 Message Date
John Safranek 13ffca4828 Fix null dereference after failed channel lookup
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.
2026-02-24 16:43:18 -08:00
John Safranek 05ec832939 Check bounds on addition with value from peer
Bounds check the bytes to add from the peer against the window size.

Affected function: DoChannelWindowAdjust.
2026-02-24 16:43:13 -08:00
John Safranek c802a7faf4 Fix null check for duplicated string
When making a copy of a string, check the destination pointer of the
copy rather than the original.

Affected function: CheckPasswordUnix.
2026-02-24 16:15:11 -08:00
David Garske 0a0341fea9
Merge pull request #880 from LinuxJedi/static-fixes
Static analysis fixes
2026-02-23 08:08:22 -08:00
Andrew Hutchings 82b9f1138d Fix NULL pointer dereference in wolfSSH_SetTpmDev/SetTpmKey
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.
2026-02-23 10:23:26 +00:00
Andrew Hutchings 99319bf773 Fix wrong variable checked in DoCheckUser auth callback
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.
2026-02-23 10:21:35 +00:00
Andrew Hutchings eab0488966 Fix octal validation loop index in GetScpFileMode
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.
2026-02-23 10:19:25 +00:00
Andrew Hutchings 6547f04a77 Fix digest comparison in FindKeyId to use id->id field
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.
2026-02-23 10:14:21 +00:00
Andrew Hutchings 0728d9cac0 Fix two bugs in PostRemoveId agent identity removal
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
2026-02-23 10:12:01 +00:00
Andrew Hutchings 4cb8d1ee99 Fix buffer over-read in wolfSSH_DoModes terminal mode parsing
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.
2026-02-23 09:56:01 +00:00
Andrew Hutchings 46cd6a7d6e Fix logical operator in public key type validation checks
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.
2026-02-23 09:28:08 +00:00
JacobBarthelmeh 4b46454af2
Merge pull request #877 from LinuxJedi/contention-testing
Add contention testing
2026-02-16 14:02:43 -07:00
Andrew Hutchings 33203c3aca Add contention testing
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.
2026-02-16 06:42:32 +00:00
JacobBarthelmeh e60aafe955
Merge pull request #876 from LinuxJedi/sftp-hang
Fix SFTP server hang on WS_WANT_WRITE with non-blocking sockets
2026-02-12 15:23:42 -07:00
JacobBarthelmeh 61d1094f9d
Merge pull request #878 from ejohnstown/fatfs-update
Update FatFS Test
2026-02-12 15:18:24 -07:00
John Safranek 804aef5b00 Update FatFS Test
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.
2026-02-12 13:14:41 -08:00
Andrew Hutchings 67c7b9cce9 Address items in the review 2026-02-12 06:40:29 +00:00
Andrew Hutchings aa1b1676cb Fix SFTP server hang on WS_WANT_WRITE with non-blocking sockets
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
2026-02-05 12:06:46 +00:00
JacobBarthelmeh d32dd2bf97
Merge pull request #873 from ejohnstown/misc-updates
Misc Updates
2026-01-28 11:01:03 -07:00
John Safranek ea45034204 Global Request functions
1. Readjust the whitespace in the Global Request functions.
2. Remove redundant logging statements.
2026-01-27 11:00:09 -08:00
John Safranek 327e1d59cd Channel Type Accessor
Each channel has a type: session, forward, etc. Add an accessor to
return the channel type for the specified channel.
2026-01-27 10:59:52 -08:00
John Safranek 023b7d777e Testsuite Update
1. Break out the echoserver test into its own function, like the SFTP
   tests, called by the testsuite.
2. whitespace
2026-01-26 16:40:18 -08:00
JacobBarthelmeh e8e5d372e3
Merge pull request #872 from ejohnstown/coverity-schedule
Coverity Scan Automation
2026-01-23 16:26:27 -07:00
John Safranek 89bcf85d50 Coverity Scan Automation
1. Add GitHub action to run a Coverity scan.
2026-01-22 14:34:38 -08:00
David Garske 1b8e0be48a
Merge pull request #869 from wolfSSL/draft-ietf-sshm-mlkem-hybrid-kex
Add mlkem1024nistp384-sha384 and mlkem768x25519-sha256
2026-01-21 12:55:14 -08:00
David Garske 4a08f35f83
Merge pull request #871 from ejohnstown/actions
GitHub Actions Update
2026-01-21 12:39:46 -08:00
John Safranek eae1ecd08b GitHub Actions Update
1. Change all actions to run on push only to master, main, or a release.
2. Change all actions to run on workflow_dispatch.
2026-01-20 15:47:45 -08:00
JacobBarthelmeh ef6b6c5961
Merge pull request #870 from ejohnstown/cov-untrusted-divisor
Coverity: Untrusted divisor
2026-01-20 14:19:04 -07:00
John Safranek aa1ea29c64 Add ML-KEM with Curve25519 and NISTp384
1. Add GitHub action to test wolfSSL against OpenSSH using MLKEM.
2026-01-20 13:16:45 -08:00
John Safranek 3f8a1b81d2 Coverity: Untrusted divisor
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
2026-01-20 11:27:48 -08:00
John Safranek fb92a35c06
Merge pull request #833 from anhu/fips_with_no_hashdrbg
Allow building with hashdrbg disabled under fips
2026-01-19 15:07:20 -08:00
John Safranek 303cafc9be Add ML-KEM with Curve25519 and NISTp384
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.
2026-01-13 21:54:27 -08:00
Anthony Hu d5d02aea51 mlkem1024nistp384-sha384 mlkem768x25519-sha256 2026-01-13 21:54:04 -08:00
JacobBarthelmeh 8b83d63e95
Merge pull request #867 from ejohnstown/paths
SFTP Paths
2026-01-13 16:40:09 -07:00
JacobBarthelmeh ef44b3817d
Merge pull request #868 from ejohnstown/fix-test-term-size
Fix Test Term Size
2026-01-13 16:32:48 -07:00
John Safranek 78e38999a1 Fix Test Term Size
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.
2026-01-13 11:33:03 -08:00
John Safranek 5cd4443e48 SFTP Paths
1. Modify the SFTP function RecvOpen() to use the same path cleanup
   function, GetAndCleanPath(), that all the other SFTP functions use.
2026-01-12 15:29:44 -08:00
John Safranek fa648eccd0
Merge pull request #864 from JacobBarthelmeh/windows_sshd 2026-01-09 17:18:10 -07:00
David Garske af1dac9910
Merge pull request #866 from JacobBarthelmeh/warninigs
fix for warning with snprintf use in test case
2026-01-09 13:54:28 -08:00
JacobBarthelmeh 069dcc0949 fix for warning with snprintf use in test case 2026-01-09 10:56:11 -07:00
JacobBarthelmeh 9097542760 use sizeof for getting the command buffer size 2026-01-09 10:40:56 -07:00
John Safranek ea563b5bcf
Merge pull request #865 from JacobBarthelmeh/windows
improvements to wolfSSH_CleanPath function used with SCP
2026-01-08 12:12:08 -07:00
JacobBarthelmeh adcb7e1588 add sanity check for Windows terminal resize 2026-01-06 16:15:27 -07:00
JacobBarthelmeh 4cc065b241 improvements to wolfSSH_CleanPath function used with SCP 2026-01-06 16:08:12 -07:00
JacobBarthelmeh 7d48298436
Merge pull request #863 from ejohnstown/release-1.4.22-2
Release v1.4.22
2026-01-05 18:44:44 -07:00
John Safranek 7f6b5b373e Fix String References
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.
2026-01-05 15:24:40 -08:00
JacobBarthelmeh fb544737f7
Merge pull request #862 from ejohnstown/strings
Fix String References
2026-01-05 14:03:30 -07:00
John Safranek 864c68afd7 Release v1.4.22
1. Update ChangeLog for release date.
2026-01-05 11:06:46 -08:00
John Safranek 48743008f8 Fix String References
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.
2026-01-05 11:06:14 -08:00
JacobBarthelmeh deddd3309c
Merge pull request #860 from ejohnstown/release-1.4.22-1
Release v1.4.22
2025-12-30 17:12:29 -07:00