Repository navigation
Reject EOF while seeking through a decompressor pipe - #38
Test-bot-cell wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #38 +/- ##
==========================================
- Coverage 94.59% 94.51% -0.09%
==========================================
Files 13 13
Lines 4092 4009 -83
==========================================
- Hits 3871 3789 -82
+ Misses 221 220 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change addressing premature EOF during archive skips.
No open issues 🎉
What changed in this PR
This PR prevents archive processing from hanging when a decompressor pipe ends before the requested skip completes.
Changes:
- Return
UnexpectedEofwhen a read yields zero bytes during a pending skip, reporting the missing byte count and preserving existing read-error propagation. - Add a real child-stdout regression test covering zero-length skips without consuming data, exact-length skips, and premature EOF.
| File | Description |
|---|---|
src/seek_forward.rs |
Detects premature pipe EOF and adds regression coverage for skip boundary behavior. |
Review effort: Balanced
aozmekik
left a comment
There was a problem hiding this comment.
Tried this on a real initrd: the Ubuntu 26.04 runner's own /boot/initrd.img (46 MB, zstd), cut to 30, 60, 90 and 99% of its size. On main, --list and --examine hang on all four after zstd's "Read error (39) : premature end" (killed after 30 s). With this branch they exit 1 right away with "missing N bytes while seeking forward ...", and the untruncated initrd still lists fine.
I ran into this hang with the truncated initrd from LP #2157789 (see #39).
When a decompressor pipe ends before the cpio payload size declared in its header, `ChildStdout::seek_forward` loops forever: `read` returns zero and `remaining` never decreases. Replace the manual read loop with `std::io::copy` into `std::io::sink()` and return `ErrorKind::UnexpectedEof` if fewer than `offset` bytes were consumed. This retains the `splice` optimization used by `std::io::copy` on Linux pipes. Add a test case similar to the minimal reproducer provided in #38.
When a decompressor pipe ends before the cpio payload size declared in its header, `ChildStdout::seek_forward` loops forever: `read` returns zero and `remaining` never decreases. Replace the manual read loop with `std::io::copy` into `std::io::sink()` and return `ErrorKind::UnexpectedEof` if fewer than `offset` bytes were consumed. This retains the `splice` optimization used by `std::io::copy` on Linux pipes. Add a test case similar to the minimal reproducer provided in #38.
|
Thanks for the PR. I converted your minimal reproducer into a test case and rewrote |
When a decompressor pipe ends before the cpio payload size declared in its header,
ChildStdout::seek_forwardloops forever:readreturns zero andremainingnever decreases. ReturnUnexpectedEofat that point, preserving the existing propagation of read errors.The regression test uses a real child stdout pipe and covers a zero-length skip without consuming data, an exact-length skip, and EOF before the requested offset.
A minimal reproducer for 0.14.0 and the current main branch:
Before the fix, the command times out. With the fix it exits with status 1 and reports the missing 3996 bytes. A native Ubuntu package built from the same fix completed this check in 17 ms; valid bzip2, gzip, lz4, lzop, xz and zstd input and zstd extraction still passed.
Validation on main
505212c916b7fefa8b53c006daa351cfe26526c5plus this change, using Rust 1.93.1:RUSTFLAGS=-Dwarnings cargo test --locked --all: 118 unit tests, 38 CLI tests and 5 doctests passed, none ignored.RUSTFLAGS=-Dwarnings cargo clippy --locked --all-targets --all-features: passed.cargo fmt --all --check: passed.The Ubuntu 26.04 CI runner uses sudo-rs, which ignores
sudo -E. The root tests passed but wrote LLVM profiles outside the expected directory. The root runner now explicitly preservesLLVM_PROFILE_FILE; all nine CI jobs pass, including generation of the root coverage report. This changes no Rust code or test assertions.The existing ISC license is retained.