Incorrect decompression
Closed this issue · 2 comments
hello, I found an example of incorrect decompression.
cat rardecode_test.go
package rardecode
import (
"fmt"
"io"
"os"
"testing"
)
func TestDecode(t *testing.T) {
ar, err := OpenReader("A62PC版+手机版.rar", "51mh")
if err != nil {
t.Fatalf("failed to open reader: %s", err)
}
for i := 0; i < 15; i++ {
af, err := ar.Next()
if err != nil {
t.Fatalf("failed to advance the next file: %s", err)
}
filePath := fmt.Sprintf("tmp/%d", i)
fw, err := os.OpenFile(filePath, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0644)
if err != nil {
t.Fatalf("failed to open file: %s", err)
}
io.CopyN(fw, ar, af.UnPackedSize)
fw.Close()
t.Logf("index: %d, name: %s, filesize: %d", i, af.Name, af.UnPackedSize)
}
}
go test -v
=== RUN TestDecode
rardecode_test.go:28: index: 0, name: A62/手机版 小白的露出受奸日记唯爱移植版.apk, filesize: 811753674
rardecode_test.go:28: index: 1, name: A62/PC版 Snower's New Clothes/credits.html, filesize: 2016436
rardecode_test.go:28: index: 2, name: A62/PC版 Snower's New Clothes/d3dcompiler_47.dll, filesize: 3661112
rardecode_test.go:28: index: 3, name: A62/PC版 Snower's New Clothes/ffmpeg.dll, filesize: 2058240
rardecode_test.go:28: index: 4, name: A62/PC版 Snower's New Clothes/Game.exe, filesize: 1604096
rardecode_test.go:28: index: 5, name: A62/PC版 Snower's New Clothes/icudtl.dat, filesize: 10171248
rardecode_test.go:28: index: 6, name: A62/PC版 Snower's New Clothes/libEGL.dll, filesize: 78848
rardecode_test.go:28: index: 7, name: A62/PC版 Snower's New Clothes/libGLESv2.dll, filesize: 3730944
rardecode_test.go:28: index: 8, name: A62/PC版 Snower's New Clothes/natives_blob.bin, filesize: 205638
rardecode_test.go:28: index: 9, name: A62/PC版 Snower's New Clothes/node.dll, filesize: 5749248
rardecode_test.go:28: index: 10, name: A62/PC版 Snower's New Clothes/nw.dll, filesize: 84381696
rardecode_test.go:28: index: 11, name: A62/PC版 Snower's New Clothes/nw_100_percent.pak, filesize: 827931
rardecode_test.go:28: index: 12, name: A62/PC版 Snower's New Clothes/nw_200_percent.pak, filesize: 1099441
rardecode_test.go:28: index: 13, name: A62/PC版 Snower's New Clothes/nw_elf.dll, filesize: 450048
rardecode_test.go:28: index: 14, name: A62/PC版 Snower's New Clothes/package.json, filesize: 243
--- PASS: TestDecode (33.16s)
PASS
ok github.com/nwaples/rardecode 33.161s
ls -ltr ./tmp
-rw-r--r-- 1 811753674 15:33 0
-rw-r--r-- 1 2016436 15:33 1
-rw-r--r-- 1 3661112 15:33 2
-rw-r--r-- 1 2058240 15:33 3
-rw-r--r-- 1 1604096 15:33 4
-rw-r--r-- 1 10171248 15:33 5
-rw-r--r-- 1 78848 15:33 6
-rw-r--r-- 1 3730944 15:33 7
-rw-r--r-- 1 205638 15:33 8
-rw-r--r-- 1 5749248 15:33 9
-rw-r--r-- 1 46071812 15:33 10
-rw-r--r-- 1 827931 15:33 11
-rw-r--r-- 1 1099441 15:33 12
-rw-r--r-- 1 450048 15:33 13
-rw-r--r-- 1 243 15:33 14
the rar file: A62PC版+手机版.rar download link:
https://drive.google.com/file/d/1yEd3cUGKDw-nyDo64kmv9GDe8ljsmLLI/view?usp=sharing
the filesize of 10th file is expected to be 84381696 but actual size is 46071812,what‘s the problem?
I committed a fix to master. Let me know if thats ok and Ill tag v1.1.1
thanks, It's fixed.