From cad1f451fda768e180eaaa5ad722c6e9c9c728ab Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Fri, 21 Jul 2023 08:50:40 -0400 Subject: [PATCH 1/2] tar/asm: troubleshooting padding EOF issue Reference #65 Signed-off-by: Vincent Batts --- tar/asm/assemble_test.go | 1 + ...226599576bafa38490b1e292375c90de095855b64caea6 | Bin 0 -> 117 bytes 2 files changed, 1 insertion(+) create mode 100644 tar/asm/testdata/1c51fc286aa95d9413226599576bafa38490b1e292375c90de095855b64caea6 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) { diff --git a/tar/asm/testdata/1c51fc286aa95d9413226599576bafa38490b1e292375c90de095855b64caea6 b/tar/asm/testdata/1c51fc286aa95d9413226599576bafa38490b1e292375c90de095855b64caea6 new file mode 100644 index 0000000000000000000000000000000000000000..12243c722fed5b7923e3170769b4b2588ebbbfad GIT binary patch literal 117 zcmb2|=3oE;CT49-E#K4yh6W5w!NI`>yeu!aG%no9Ifqx!+}PM8DZn6M0kej#o~KSw zK!U`=1^2EV@9mr@crHC@Lo&lhEeV+eHS9W7G7>rx304j!+Ou?wVws;_J@8b~aqq#l V`BM``cq|wg8rVuEF|aT&007^wB*y>% literal 0 HcmV?d00001 From b6372414e507319c619a5e63129b0956d46ffc6e Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Fri, 21 Jul 2023 08:59:22 -0400 Subject: [PATCH 2/2] tar/asm: don't add a padding entry if it has no bytes Fixes #65 if the read bytes is 0, then don't even create the entry for that padding. This sounds like the solution for the issue opened, but I haven't found a reproducer for this issue yet. :-\ Signed-off-by: Vincent Batts --- tar/asm/disassemble.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tar/asm/disassemble.go b/tar/asm/disassemble.go index 009b3f5..33cffba 100644 --- a/tar/asm/disassemble.go +++ b/tar/asm/disassemble.go @@ -135,6 +135,9 @@ func NewInputTarStream(r io.Reader, p storage.Packer, fp storage.FilePutter) (io } isEOF = true } + if n == 0 { + break + } _, err = p.AddEntry(storage.Entry{ Type: storage.SegmentType, Payload: paddingChunk[:n],