Uh oh!
There was an error while loading. Please reload this page.
Accept exact-fit ScpBuffer in no-filesystem SCP send callback - #1161
Accept exact-fit ScpBuffer in no-filesystem SCP send callback#1161yosuke-wolfssl wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes the default NO_FILESYSTEM SCP send callback to correctly allow exact-fit ScpBuffer transfers (where bufferSz == fileSz) and hardens bounds checking to prevent underflow/overflow paths, then adds targeted unit coverage and CI to ensure the NO_FILESYSTEM build path is compiled and tested.
Changes:
- Adjusts
wsScpSendCallback()capacity/idx guards to accept exact-fit buffers and reject out-of-range indices safely. - Adds a new unit test covering exact-fit single/multi-chunk sends, boundary rejects, underflow shapes, and NULL
statuscallback handling underNO_FILESYSTEM. - Introduces a GitHub Actions workflow to build and run unit tests with
-DNO_FILESYSTEM.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/wolfscp.c | Fixes exact-fit handling and strengthens bounds checks in the no-filesystem SCP send callback. |
tests/unit.c | Adds a dedicated unit test for exact-fit/no-filesystem SCP send behavior and edge cases. |
.github/workflows/no-filesystem-check.yml | Adds CI coverage to compile and run unit tests with NO_FILESYSTEM enabled. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
361fe06 to
9c0f483Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1161
Scan targets checked:wolfssh-bugs, wolfssh-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
Uh oh!
There was an error while loading. Please reload this page.
9c0f483 to
f806547CompareUh oh!
There was an error while loading. Please reload this page.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1161
Scan targets checked:wolfssh-bugs, wolfssh-src
No new issues found in the changed files. ✅
ejohnstown
left a comment
There was a problem hiding this comment.
One thing to fix before merge. The CI step runs ./tests/unit.test | tee unit-test.log under bash -e with no pipefail, so the pipeline's status is tee's. Any other unit test failing is swallowed, and only the grepped name gates the job. Add set -o pipefail.
f806547 to
cde7717Compareyosuke-wolfssl
commented
Aug 14, 2026
Thank you @ejohnstown, I fixed this as you suggested. |
Problem
The default no-filesystem SCP send callback (
wsScpSendCallbackunderNO_FILESYSTEMwithoutWOLFSSH_SCP_USER_CALLBACKS) rejected anyScpBufferwhosebufferSzexactly equalsfileSz: its capacity checksused
>=, so an exact-fit transfer — the natural sizing for this API —aborted with
WS_SCP_ABORTon the final chunk, or immediately when thewhole file fit one request. Logic error, High severity.
Fix (
src/wolfscp.c)>=→>on the three capacity checks, soidx + ret == bufferSz(and
idx == bufferSzin the continue state) is accepted as an exact fitand completed transfers fall through to the
WS_EOFreturn.idx > fileSzaborts in both transfer states, so the unsignedfileSz - idxsize math can never be used after wraparound on amis-populated application context.
statuscallback before invoking it inthe continue state.
Closes f-8821 and f-8822.
Tests (
tests/unit.c)New
test_ScpSendCallback_ExactFitBuffer: exact-fit single- andmulti-chunk transfers,
WS_EOFafter completion, oversized-filerejection, one-past-the-boundary reject cases for each relaxed guard,
underflow shapes where the
idx > fileSzcheck is the only rejectionpath, and a NULL
statuscallback.CI (
.github/workflows/os-check.yml)No existing workflow defined
NO_FILESYSTEM, so the changed code and itstest were compiled nowhere in CI. A
build_wolfssh_no_filesystemjob isadded to the os-check workflow, reusing its cached wolfSSL builds and
version matrix (master plus the two latest releases). It builds
tests/unit.testdirectly — the examples do not build without afilesystem (pre-existing, unrelated) — runs it, and requires the new test
to appear and pass, failing on silent compile-out.
Verification
NO_FILESYSTEMjob ran green on this PR withScpSendCallback_ExactFitBuffer: SUCCESSin the log.NO_FILESYSTEMconfig: unit test clean under ASan + UBSan.-Werrorpreflight cleanon 6 configs.