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

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tar.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tar.ts

Lines changed: 10 additions & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy