Skip to content

Commit 1bb15d0

Browse files
authored
Merge pull request #2768 from github/smowton/fix/zstd-tarball-trailing-zeros
Pass `--ignore-zeros` to `tar` when decompressing `zstd`-compressed tarballs
2 parents acadfed + c4158ff commit 1bb15d0

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

lib/tar.js

+10-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tar.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tar.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,16 @@ export async function extractTarZst(
168168

169169
try {
170170
// Initialize args
171-
const args = ["-x", "--zstd"];
171+
//
172+
// `--ignore-zeros` means that trailing zero bytes at the end of an archive will be read
173+
// by `tar` in case a further concatenated archive follows. Otherwise when a tarball built
174+
// by GNU tar, which writes many trailing zeroes, is read by BSD tar, which expects less, then
175+
// BSD tar can hang up the pipe to its filter program early, and if that program is `zstd`
176+
// then it will try to write the remaining zeroes, get an EPIPE error because `tar` has closed
177+
// its end of the pipe, return 1, and `tar` will pass the error along.
178+
//
179+
// See also https://github.com/facebook/zstd/issues/4294
180+
const args = ["-x", "--zstd", "--ignore-zeros"];
172181

173182
if (tarVersion.type === "gnu") {
174183
// Suppress warnings when using GNU tar to extract archives created by BSD tar

0 commit comments

Comments
 (0)