Skip to content

Commit 0c47e8d

Browse files
committed
xtask: Drain vendor tar stream to avoid zstd SIGPIPE
The tar crate stops reading when it reaches the end-of-archive marker, before the zero padding that follows it. The pipe was then closed while zstd was still writing that padding, so zstd was killed by SIGPIPE and `cargo xtask package` failed. Read the rest of the stream before returning. Assisted-by: AI Signed-off-by: John Eckersberg <dev@eckersberg.com>
1 parent d3b33bc commit 0c47e8d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎crates/xtask/src/xtask.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ fn vendor_denied_crate(path: &Utf8Path) -> Option<&'static str> {
532532
/// [`VENDOR_DENYLIST`].
533533
fn vendor_denied_entries(archive: impl std::io::Read) -> Result<Vec<String>> {
534534
let mut denied = Vec::new();
535-
for entry in tar::Archive::new(archive).entries()? {
535+
let mut archive = tar::Archive::new(archive);
536+
for entry in archive.entries()? {
536537
let entry = entry?;
537538
let path = entry.path()?;
538539
let path = path.to_string_lossy();
@@ -542,6 +543,9 @@ fn vendor_denied_entries(archive: impl std::io::Read) -> Result<Vec<String>> {
542543
denied.push(format!("{path} (from {name})"));
543544
}
544545
}
546+
// Drain trailing padding after the end-of-archive marker so the
547+
// writer (zstd) doesn't get SIGPIPE.
548+
std::io::copy(&mut archive.into_inner(), &mut std::io::sink())?;
545549
Ok(denied)
546550
}
547551

0 commit comments

Comments
 (0)