Skip to content

Commit eaf4b06

Browse files
committed
[zstd_test] Add a test for ZipBomb payload on Decompress
See #60
1 parent 393c3c1 commit eaf4b06

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

zstd_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package zstd
22

33
import (
44
"bytes"
5+
b64 "encoding/base64"
56
"errors"
67
"fmt"
78
"io/ioutil"
@@ -284,6 +285,14 @@ func TestLegacy(t *testing.T) {
284285
}
285286
}
286287

288+
func TestBadPayloadZipBomb(t *testing.T) {
289+
payload, _ := b64.StdEncoding.DecodeString("KLUv/dcwMDAwMDAwMDAwMAAA")
290+
_, err := Decompress(nil, payload)
291+
if err.Error() != "Src size is incorrect" {
292+
t.Fatal("zstd should detect that the size is incorrect")
293+
}
294+
}
295+
287296
func BenchmarkCompression(b *testing.B) {
288297
if raw == nil {
289298
b.Fatal(ErrNoPayloadEnv)

0 commit comments

Comments
 (0)