Refactor of the echoserver example only; library is unchanged.
1. Collapse FwdStates and AGENT_STATE_* into a single WS_AppState
(INIT/LISTEN/CONNECT/CONNECTED). FWD_STATE_DIRECT becomes an
isDirect flag, cleared after connect.
2. Hoist the fields shared by the forwarding, agent, and shell paths
into a common WS_AppCtx (privateData, listenFd, appFd, channelId,
state, buffer). Shell only uses buffer.
3. Feature-specific remainder stays in WS_AgentCbActionCtx (name) and
WS_FwdCbActionCtx (host/origin name+port, isDirect). Drop the unused
pid field; inline getpid() at the call site.
4. wolfSSH_AGENT_DefaultActions and wolfSSH_FwdDefaultActions now take
a WS_AppCtx* and reach feature-specific state via
appCtx->privateData. echoserver_test() is updated to register the
WS_AppCtx (not the old CbCtx) with wolfSSH_set_agent_cb_ctx and
wolfSSH_SetFwdCbCtx.
5. Reindent ssh_worker()'s #ifdef blocks and add /* WOLFSSH_xxx */
markers.
6. fwd.test.expect: redirect echoserver and portfwd output to log files
and sync on portfwd's -R ready file instead of matching "sampled" in
the pty. Under --enable-debug the WLOG volume fills the pty and
stalls portfwd in select() before channel-open.
Replace the hand-written ato32 plus localIdx + N > maxIdx checks in
SFTP_ParseAttributes_buffer with GetUint32 and GetSkip, and drop the
manual length plus copy sequences in wolfSSH_SFTP_DoStatus and
wolfSSH_SFTP_DoName in favor of GetStringRef so the bounds-check
arithmetic lives in one place.
Convert the unflagged server Recv* handlers (RecvRealPath, RecvRMDIR,
RecvMKDIR, RecvOpenDir, RecvReadDir, RecvClose, RecvRemove, RecvFSTAT,
RecvSTAT, RecvLSTAT, RecvSetSTAT, RecvFSetSTAT) to GetStringRef,
GetSize, and GetUint32 so all Recv* paths share one bounds-checked
idiom.
Convert RecvOpen, RecvWrite, RecvRead, and RecvRename (POSIX and
Windows) to GetUint32, GetSize, and GetStringRef so each ato32 reads
only what the buffer can supply.
Issue: F-412
1. Client skips non-SSH lines (RFC 4253 4.2); server rejects them
2. 255-byte per-line cap and 10-line cap (WOLFSSH_MAX_BANNER_LINES)
3. 28 test vectors plus scripted-IO mock for WANT_READ resumption
Issue: F-606
When a server sends first_kex_packet_follows=TRUE with an incorrect KEX
algorithm guess, the client now silently discards the server's speculative
KEXDH_REPLY message by checking ignoreNextKexMsg at the top of DoKexDhReply,
matching the existing server-side handling in DoKexDhInit. Add regression
test covering the client-side skip path.
Affected functions: DoKexDhReply.
Issue: F-2863
The project file for the wolfSFTP example client is specifying a
too-specific Windows target platform version. It is the only project
file specifying the version to four places. Removed it and using the
default Windows version for the version of the build tools.
1. Collect all the test function wrappers in internal.c to one location
at the end of the file.
2. Update API test to check other algos if RSA or ECDSA are disabled.
3. Added guarded tests TestClientBuffersIdempotent() for WOLFSSH_NO_RSA
and WOLFSSH_NO_ECDSA_SHA2_NISTP256. If both are set, the test is
skipped.
When processing the KEX Init message, stash guesses for the peer's
KEX and public key algorithms. When reading first_packet_follows, if set
check the guesses and set the handshake info flag ignoreNextKexMsg. When
processing the KexDhInit message, check that flag.
Affected functions: DoKexInit, DoKexDhInit.
Issue: F-1686
Replace rewind() with fseek(f, 0, SEEK_SET) in the test helper
function. rewind() internally clears errno, which scan-build flags
as overwriting a previously unchecked errno value. fseek() to
offset 0 is functionally equivalent without the implicit errno
reset.
Replace rewind() with fseek(s, 0, SEEK_SET) in the WREWIND macro.
rewind() internally clears errno, which scan-build flags as
overwriting a previously unchecked errno value. fseek() to offset 0
is functionally equivalent without the implicit errno reset.
Remove the errno check in the condition after execv(). If execv()
returns at all, it has failed, so checking ret alone is sufficient.
The errno check was flagged by clang scan-build as potentially
reading an undefined value (unix.Errno).
Static analysis indicated the potential to double-free a pointer in the
`wolfSSH_CTX_UseCert_buffer()` test. Loading the second cert after
freeing the first cert could fail and the test cleanup would free the
pointer again. Just set pointer to null after freeing.
When wolfsshd is built with WOLFSSH_ALLOW_USERAUTH_NONE, the
DefaultUserAuth() function accepted WOLFSSH_USERAUTH_NONE as a valid
auth type and forwarded it to RequestAuthentication(). Since
RequestAuthentication() only gates credential checks on PASSWORD and
PUBLICKEY types, a none request for any existing system user returned
success without verifying any credential. Removed USERAUTH_NONE as an
accepted auth type in DefaultUserAuth() so it is treated as an invalid
auth type for wolfsshd.
Affected function: DefaultUserAuth.
Issue: F-3215