Skip to content

Commit

Permalink
Avoid using max() and underscores in numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
jsha committed Mar 7, 2024
1 parent 158656a commit 15e60b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion encoding.go
Expand Up @@ -106,7 +106,10 @@ func inflate(input []byte) ([]byte, error) {
output := new(bytes.Buffer)
reader := flate.NewReader(bytes.NewBuffer(input))

maxCompressedSize := max(250_000, 10*int64(len(input)))
maxCompressedSize := 10 * int64(len(input))
if maxCompressedSize < 250000 {
maxCompressedSize = 250000
}

limit := maxCompressedSize + 1
n, err := io.CopyN(output, reader, limit)
Expand Down
4 changes: 2 additions & 2 deletions encoding_test.go
Expand Up @@ -63,7 +63,7 @@ func TestInvalidCompression(t *testing.T) {
// compression ratio is reasonable.
func TestLargeZip(t *testing.T) {
input := new(bytes.Buffer)
_, err := io.CopyN(input, rand.Reader, 251_000)
_, err := io.CopyN(input, rand.Reader, 251000)
if err != nil {
t.Fatalf("generating input: %s", err)
}
Expand All @@ -79,7 +79,7 @@ func TestLargeZip(t *testing.T) {
}

func TestZipBomb(t *testing.T) {
input := strings.Repeat("a", 251_000)
input := strings.Repeat("a", 251000)
compressed, err := compress(DEFLATE, []byte(input))
if err != nil {
t.Errorf("compressing: %s", err)
Expand Down

0 comments on commit 15e60b7

Please sign in to comment.