Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

zip: unable to unarchive file with LZMA compression method #225

Closed
FeNoMeNa opened this issue Jul 4, 2020 · 4 comments
Closed

zip: unable to unarchive file with LZMA compression method #225

FeNoMeNa opened this issue Jul 4, 2020 · 4 comments

Comments

@FeNoMeNa
Copy link

FeNoMeNa commented Jul 4, 2020

What version of the package or command are you using?

d44471c

What are you trying to do?

I'm trying to unarchive a zip file with LZMA compression method.

What steps did you take?

z.Unarchive("package.zip", "test")

package.zip is a zip archive with LZMA compression.

What did you expect to happen, and what actually happened instead?

A successful decompressing is expected, but a panic is thrown:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x6a5359]

goroutine 1 [running]:
archive/zip.(*checksumReader).Close(0xc00007a050, 0x7c9d40, 0xc0000b82c0)
        /usr/local/go/src/archive/zip/reader.go:234 +0x29
github.com/mholt/archiver/v3.(*Zip).extractNext(0xc00010ff48, 0x752ba4, 0x4, 0x7c35a0, 0xc000012030)
        /home/username/Workspace/Go/pkg/mod/github.com/mholt/archiver/v3@v3.3.1-0.20200626164424-d44471c49aa7/zip.go:237 +0x15a
github.com/mholt/archiver/v3.(*Zip).Unarchive(0xc00010ff48, 0x75460d, 0xb, 0x752ba4, 0x4, 0x0, 0x0)
        /home/username/Workspace/Go/pkg/mod/github.com/mholt/archiver/v3@v3.3.1-0.20200626164424-d44471c49aa7/zip.go:215 +0x39c
main.main()
        /home/username/Workspace/Go/src/test/main.go:25 +0x7d

How do you think this should be fixed?

The bug is occurred in the LZMA decompressor.

newRangeDecoder: first byte not zero
	z.zr.RegisterDecompressor(uint16(LZMA), func(r io.Reader) io.ReadCloser {
		lr, err := lzma.NewReader(r)
		if err != nil {
			log.Println(err)
			return nil
		}
		return ioutil.NopCloser(lr)
	})
@mholt
Copy link
Owner

mholt commented Jul 6, 2020

/cc @fcharlie do you have a chance to look at this?

@fcharlie
Copy link
Contributor

fcharlie commented Jul 6, 2020

@FeNoMeNa May I ask what compression software (7-zip?) you used to create a zip(LZMA) file.

@fcharlie
Copy link
Contributor

fcharlie commented Jul 6, 2020

@mholt @FeNoMeNa I tried it, and it is indeed impossible to unzip ZIP+LZMA. In fact, ZIP+LZMA has been disabled in libzip, so we can also disable it here.

ZIP+LZMA is disabled #226

@Dean-Coakley
Copy link
Contributor

This issue can be closed?

@mholt mholt closed this as completed Jan 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants