Skip to content

Report close failures when writing a tar archive - #424

Merged
folbricht merged 2 commits into
masterfrom
fix-untar-close-errors
Sep 3, 2026
Merged

folbricht merged 2 commits into
masterfrom
fix-untar-close-errors

Conversation

@folbricht

Copy link
Copy Markdown
Owner

The gnu-tar output path closed both the tar writer and the file it wrote to with the error discarded. Closing the tar writer is what writes the padding and the two end-of-archive blocks, so a failure there — a full disk, a broken pipe — left a truncated archive behind and still exited 0.

Nothing downstream reports it either: both archive/tar and GNU tar read an archive with no end-of-archive marker without complaint. On the test archive the difference is 8704 bytes against 7680, and neither reader minds.

Both closes now go into the returned error, the way the disk output path already handled its own. closeInto replaces the three copies of that pattern this would otherwise need, and is covered directly; the command test checks that the archive it writes ends with the marker, since parsing it is not enough to notice.

The gnu-tar output path closed both the tar writer and the file it wrote
to with the error discarded. Closing the tar writer is what writes the
padding and the two end-of-archive blocks, so a failure there, on a full
disk or a broken pipe, left a truncated archive behind and still exited
0. Readers accept an archive with no end-of-archive marker, so nothing
downstream reports it either.

Both closes now go into the returned error, the way the disk output path
already handled its own. The shared helper for that replaces the three
copies this would otherwise need.
@folbricht
folbricht merged commit 76d89ac into master Sep 3, 2026
9 checks passed
@folbricht
folbricht deleted the fix-untar-close-errors branch September 3, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

⌂ 换网址