From 7f14c779636ed5208f4b81e7e6508ace960b5aad Mon Sep 17 00:00:00 2001 From: Matt Dainty Date: Sat, 27 May 2023 23:05:04 +0100 Subject: [PATCH 1/2] Add another test case for empty file processing --- reader_test.go | 4 ++++ testdata/issue87.7z | Bin 0 -> 195 bytes 2 files changed, 4 insertions(+) create mode 100644 testdata/issue87.7z diff --git a/reader_test.go b/reader_test.go index 1e9d47d..ce6e380 100644 --- a/reader_test.go +++ b/reader_test.go @@ -136,6 +136,10 @@ func TestOpenReader(t *testing.T) { name: "sparc", file: "sparc.7z", }, + { + name: "issue 87", + file: "issue87.7z", + }, } for _, table := range tables { diff --git a/testdata/issue87.7z b/testdata/issue87.7z new file mode 100644 index 0000000000000000000000000000000000000000..65160f67415ec32ccaa4a51ae70789e4414b2ebf GIT binary patch literal 195 zcmXr7+Ou9=hJiUS>`y@x0|Y2S>Efl=_AyBGG;OvjUjP(pG-hAN|KLqga?<508_m+t zo*3W6rYhe%K}}3^CrGX8*U$>CD1K_7ZFK(WCi!&%HBy)Uu(2#U`f;Drj?3-lYqM0o zG5o4`dt#$nTRW{(;IGH?TX}IQ=gSY*e%qiM;Ci9JGxDopxc$woqA!BGbnjl6xTnhM o1khS>Hcm#)N(OdrMg~S@W=2NVSOx(G2A+l$T#P}yQS%uX0QE*kkN^Mx literal 0 HcmV?d00001 From ef8fd8ac145522abdd2d6e91e821ade02213831e Mon Sep 17 00:00:00 2001 From: Matt Dainty Date: Sat, 27 May 2023 23:06:08 +0100 Subject: [PATCH 2/2] Only increment counter for empty streams Avoids slice panic when block contains mix of non-empty and empty files, with the empty files not at the beginning of the block. Fixes #87 --- types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types.go b/types.go index d03a351..12e0df8 100644 --- a/types.go +++ b/types.go @@ -705,8 +705,8 @@ func readFilesInfo(r util.Reader) (*filesInfo, error) { for i := range f.file { if f.file[i].isEmptyStream { f.file[i].isEmptyFile = empty[j] + j++ } - j++ } case idCTime: times, err := readTimes(r, files)