Skip to content

Add byte-based legacy greeting parser - #7

Merged
oferchen merged 1 commit into
masterfrom
codex/build-pure-rust-rsync-3.4.1-implementation
Oct 15, 2025
Merged

oferchen merged 1 commit into
masterfrom
codex/build-pure-rust-rsync-3.4.1-implementation

Conversation

@oferchen

@oferchen oferchen commented Oct 15, 2025 •

Copy link
Copy Markdown
Owner

Summary

  • add a byte-oriented helper for parsing legacy @rsyncd greetings
  • reject invalid UTF-8 with a malformed greeting error and cover the cases with new tests

Testing

  • cargo test

@oferchen
oferchen merged commit c8fc67e into master Oct 15, 2025
@oferchen
oferchen deleted the codex/build-pure-rust-rsync-3.4.1-implementation branch October 15, 2025 11:20
oferchen added a commit that referenced this pull request May 22, 2026
#4729)

Captures the receiver-side `--delete` wiring follow-up SEC-1.q (PR #4728)
intentionally deferred. The merged engine-side work added a sandbox-aware
DeleteFs trait surface plus the DeleteEmitter::with_sandbox carrier, but
the receiver loop in crates/transfer/src/receiver/directory/deletion.rs
still calls std::fs::remove_file / remove_dir_all / read_dir directly.

Lays out three options (migrate receiver to DeleteEmitter, swap to
fast_io *_via_sandbox_or_fallback helpers, defer behind Landlock) with
LoC scope, risk, test cost, and cross-platform plan. Recommends Option B
(direct helper swap) on effort-vs-risk grounds and because the SEC-1.r
temp_guard / temp_cleanup PR (#4723) is the established precedent for
exactly this carrier-threading shape.

Closes audit rows #5-#7 in docs/audits/sec-1-path-syscall-audit-2026-05-22.md
once the implementation PR lands. Docs-only.
oferchen added a commit that referenced this pull request May 22, 2026
…-1.q2) (#4732)

* feat(transfer): thread DirSandbox through receiver --delete path (SEC-1.q2)

Replace the three unanchored syscalls in delete_extraneous_files with
their sandbox-anchored siblings so a TOCTOU symlink swap on a top-level
extraneous entry cannot redirect the listing or the unlink to an
attacker-chosen inode outside the destination tree.

Adds fast_io::read_dir_via_sandbox_or_fallback (mirrors the existing
*_via_sandbox_or_fallback shape: openat(O_DIRECTORY | O_NOFOLLOW) +
fdopendir for single-component scans, std::fs::read_dir fallback
otherwise). Closes audit rows #5, #6, #7 from the SEC-1 path-syscall
audit.

Mirrors the SEC-1.r temp_guard/temp_cleanup carrier-threading pattern
(PR #4723): the Option<Arc<DirSandbox>> is cloned once into the
map_blocking worker closure and forwarded to every helper call.
Sandbox-off and multi-component paths take the documented identical-
behaviour fallback. No transfer-crate unsafe is introduced; all unsafe
stays behind the existing fast_io safe wrappers.

Windows continues through std::fs::remove_file / remove_dir_all /
read_dir (NTFS handle semantics already close the symlink-swap window
per the SEC-1.l audit).

* fix(engine): use Components::next() walk for plan_directory_to_relative

SkipWhile<Components, _> has no as_path() method on stable Rust 1.88;
the previous skip_while-then-as_path call introduced in SEC-1.q (#4728)
slipped through that PR's CI but breaks fmt+clippy on every subsequent
master CI run. Switch to a manual Components::next() walk that consumes
the leading Prefix/RootDir/CurDir components, then calls as_path() on
the unwrapped Components iterator.

* fix(transfer): cfg-gate rel_for_unlink to unix to silence Windows unused-var
oferchen added a commit that referenced this pull request Jun 5, 2026
* perf: eliminate heap allocations in format_decimal_bytes

Replace Vec<String> intermediate allocation with a fixed [u8; 26]
stack buffer. The previous implementation created a String from
to_string(), split it into a Vec<String> of 3-digit groups, then
joined with commas - allocating 3+ heap objects per call. The new
implementation writes digits and commas right-to-left into a stack
buffer, producing a single String allocation.

RSS-2 profiling identified this function as allocation site #7,
responsible for 4.9% (9.6 MB) of total allocations at 100K files.

* fix: resolve formatting issues
oferchen added a commit that referenced this pull request Aug 24, 2026
#4729)

Captures the receiver-side `--delete` wiring follow-up SEC-1.q (PR #4728)
intentionally deferred. The merged engine-side work added a sandbox-aware
DeleteFs trait surface plus the DeleteEmitter::with_sandbox carrier, but
the receiver loop in crates/transfer/src/receiver/directory/deletion.rs
still calls std::fs::remove_file / remove_dir_all / read_dir directly.

Lays out three options (migrate receiver to DeleteEmitter, swap to
fast_io *_via_sandbox_or_fallback helpers, defer behind Landlock) with
LoC scope, risk, test cost, and cross-platform plan. Recommends Option B
(direct helper swap) on effort-vs-risk grounds and because the SEC-1.r
temp_guard / temp_cleanup PR (#4723) is the established precedent for
exactly this carrier-threading shape.

Closes audit rows #5-#7 in docs/audits/sec-1-path-syscall-audit-2026-05-22.md
once the implementation PR lands. Docs-only.
oferchen added a commit that referenced this pull request Aug 24, 2026
…-1.q2) (#4732)

* feat(transfer): thread DirSandbox through receiver --delete path (SEC-1.q2)

Replace the three unanchored syscalls in delete_extraneous_files with
their sandbox-anchored siblings so a TOCTOU symlink swap on a top-level
extraneous entry cannot redirect the listing or the unlink to an
attacker-chosen inode outside the destination tree.

Adds fast_io::read_dir_via_sandbox_or_fallback (mirrors the existing
*_via_sandbox_or_fallback shape: openat(O_DIRECTORY | O_NOFOLLOW) +
fdopendir for single-component scans, std::fs::read_dir fallback
otherwise). Closes audit rows #5, #6, #7 from the SEC-1 path-syscall
audit.

Mirrors the SEC-1.r temp_guard/temp_cleanup carrier-threading pattern
(PR #4723): the Option<Arc<DirSandbox>> is cloned once into the
map_blocking worker closure and forwarded to every helper call.
Sandbox-off and multi-component paths take the documented identical-
behaviour fallback. No transfer-crate unsafe is introduced; all unsafe
stays behind the existing fast_io safe wrappers.

Windows continues through std::fs::remove_file / remove_dir_all /
read_dir (NTFS handle semantics already close the symlink-swap window
per the SEC-1.l audit).

* fix(engine): use Components::next() walk for plan_directory_to_relative

SkipWhile<Components, _> has no as_path() method on stable Rust 1.88;
the previous skip_while-then-as_path call introduced in SEC-1.q (#4728)
slipped through that PR's CI but breaks fmt+clippy on every subsequent
master CI run. Switch to a manual Components::next() walk that consumes
the leading Prefix/RootDir/CurDir components, then calls as_path() on
the unwrapped Components iterator.

* fix(transfer): cfg-gate rel_for_unlink to unix to silence Windows unused-var
oferchen added a commit that referenced this pull request Aug 24, 2026
* perf: eliminate heap allocations in format_decimal_bytes

Replace Vec<String> intermediate allocation with a fixed [u8; 26]
stack buffer. The previous implementation created a String from
to_string(), split it into a Vec<String> of 3-digit groups, then
joined with commas - allocating 3+ heap objects per call. The new
implementation writes digits and commas right-to-left into a stack
buffer, producing a single String allocation.

RSS-2 profiling identified this function as allocation site #7,
responsible for 4.9% (9.6 MB) of total allocations at 100K files.

* fix: resolve formatting issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant