Skip to content

Commit

Permalink
[zstd_test] Add a test for ZipBomb payload on Decompress
Browse files Browse the repository at this point in the history
See #60
  • Loading branch information
Viq111 committed Apr 6, 2022
1 parent 393c3c1 commit eaf4b06
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions zstd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package zstd

import (
"bytes"
b64 "encoding/base64"
"errors"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -284,6 +285,14 @@ func TestLegacy(t *testing.T) {
}
}

func TestBadPayloadZipBomb(t *testing.T) {
payload, _ := b64.StdEncoding.DecodeString("KLUv/dcwMDAwMDAwMDAwMAAA")
_, err := Decompress(nil, payload)
if err.Error() != "Src size is incorrect" {
t.Fatal("zstd should detect that the size is incorrect")
}
}

func BenchmarkCompression(b *testing.B) {
if raw == nil {
b.Fatal(ErrNoPayloadEnv)
Expand Down

0 comments on commit eaf4b06

Please sign in to comment.