Empty entry added when no padding at end of file
Closed this issue · 3 comments
I've run into an issue where an empty entry is added when reading a tar stream and I wanted to check if this was expected behaviour or not?
I have a scenario where this read operation
tar-split/tar/asm/disassemble.go
Line 130 in f966b14
n=0
and err=EOF
In other places in this code you are checking that the length of the payload is greater than 0
tar-split/tar/asm/disassemble.go
Lines 57 to 66 in f966b14
Should this length check also be applied when adding the padding chunk or is adding the empty entry desired?
thanks for reporting. Do you have a reproducer for this situation?
Ooh, if this is what I think it is (the trailing "EOF" entry), then it might be useful to you that I just recently refactored the layer on tianon/true:oci
to not include that (in case you need a very small test case).
I just tried your layer from that tianon/true:oci
image, but it passes right through this code and doesn't hit the issue.
diff --git a/tar/asm/assemble_test.go b/tar/asm/assemble_test.go
index 6cb7850..cfbcca6 100644
--- a/tar/asm/assemble_test.go
+++ b/tar/asm/assemble_test.go
@@ -140,6 +140,7 @@ var testCases = []struct {
{"./testdata/iso-8859.tar.gz", "ddafa51cb03c74ec117ab366ee2240d13bba1ec3", 10240},
{"./testdata/extranils.tar.gz", "e187b4b3e739deaccc257342f4940f34403dc588", 10648},
{"./testdata/notenoughnils.tar.gz", "72f93f41efd95290baa5c174c234f5d4c22ce601", 512},
+ {"./testdata/1c51fc286aa95d9413226599576bafa38490b1e292375c90de095855b64caea6", "946caa03167a8cc707db6ff9785608b652e631dc", 1024},
}
func TestTarStream(t *testing.T) {