scp: return directory entries from the Zephyr entry walk - #1245
Open
yosuke-wolfssl wants to merge 1 commit into
Open
scp: return directory entries from the Zephyr entry walk#1245yosuke-wolfssl wants to merge 1 commit into
yosuke-wolfssl wants to merge 1 commit into
Conversation
- The WOLFSSH_ZEPHYR branch of FindNextDirEntry() loops while the entry name is "." or "..", matching the POSIX and Windows branches, in place of while (1). - tests/api.c gains test_wolfSSH_SCP_SendRecursiveEntry(), staging a directory holding one file and driving three WOLFSSH_SCP_RECURSIVE_REQUEST calls through wsScpSendCallback(), checking the entry name, size, and bytes placed in buf. dirPath is rooted at CONFIG_WOLFSSH_SFTP_DEFAULT_DIR under WOLFSSH_ZEPHYR and at "./scp_recur_entry" otherwise. - The test is gated on WOLFSSH_SCP, with WOLFSSH_SCP_USER_CALLBACKS, NO_FILESYSTEM and NO_WOLFSSH_DIR unset, carries an empty stub otherwise, and is called from wolfSSH_ApiTest(). - scpStageRecurFile() writes that fixture file. Issue: F-13315
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change corrects an unreachable-success logic path on Zephyr and adds a deterministic test that exercises the fixed behavior without introducing interface or behavioral risk elsewhere.
Pull request overview
This PR fixes recursive SCP directory traversal on Zephyr by making FindNextDirEntry() return actual directory entries (instead of looping until end-of-directory) and adds a focused API-level test to prevent regressions in Zephyr CI.
Changes:
- Fix Zephyr
FindNextDirEntry()to skip./..and fall through toWS_SUCCESS, aligning behavior with other platforms. - Add
test_wolfSSH_SCP_SendRecursiveEntry()that directly driveswsScpSendCallback()through enter-dir → one file entry → final exit, including dot-entry skipping behavior.
File summaries
| File | Description |
|---|---|
src/wolfscp.c |
Makes Zephyr directory entry walking return real entries by skipping ./.. and allowing WS_SUCCESS to be reached. |
tests/api.c |
Adds a Zephyr-capable recursive-send callback-level test to validate directory entry iteration and completion signaling. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Author
|
CI issues would be gone once PR #1242 is merged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
WOLFSSH_ZEPHYRbranch ofFindNextDirEntry()ended inwhile (1), discarding every entryfs_readdir()returned. It could only reachreturn WS_FATAL_ERRORorreturn WS_NEXT_ERROR— the sharedreturn WS_SUCCESSwas unreachable on Zephyr.That function is called only from the
WOLFSSH_SCP_RECURSIVE_REQUESTarm ofwsScpSendCallback(), and the caller readsWS_NEXT_ERRORas end-of-directory. A peer runningscp -r user@host:dir .against a Zephyr server got the directory header and an immediate exit, so every directory transferred empty. Single-file SCP was unaffected. Functional only — no overflow or leak, and the loop always terminated, sincefs_readdir()signals end-of-directory withname[0] = 0.Fix (
src/wolfscp.c)Skip
.and..and fall through toreturn WS_SUCCESS, matching the POSIX and Windows branches:The skip is not cosmetic everywhere:
./..?dir_read()filters leading.lfs_dir_read_()synthesizes both.is a directory andScpPushDir()re-descends the same directory unboundedlyCloses f-13315.
Tests (
tests/api.c)test_wolfSSH_SCP_SendRecursiveEntry()stages a one-file directory and drives threeWOLFSSH_SCP_RECURSIVE_REQUESTcalls throughwsScpSendCallback(), asserting enter-dir, then the entry name/size/bytes, then final exit. Driving the callback directly is the only route in — the example client cannot issuescp -r -f. It needs no threads, sockets,mkdtempor symlinks, so unlike every other SCP test it is not gated!defined(WOLFSSH_ZEPHYR)and runs in the Zephyr CI.Verification
make check: 8 passed, 3 skipped, 0 failed.gcc-13 -Werrorsweep: 6/6 configs clean.Zephyr wolfSSH tests passed.while (1)restored, the Zephyr run fails at the new assertion (-1047instead of 64 bytes); with the POSIX dot-skip disabled, it fails with-1045, having descended into..Not in this PR
Nested-subdirectory descent (the non-final
WS_SCP_EXIT_DIR) and the empty-directory case stay uncovered — both pre-existing gaps, flagged in review and deferred.