Skip to content

Commit

Permalink
sumdb/tlog: fuzz ParseTilePath
Browse files Browse the repository at this point in the history
  • Loading branch information
hickford committed Feb 23, 2023
1 parent 774e778 commit 6fff4e6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sumdb/tlog/note_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,15 @@ func TestParseRecord(t *testing.T) {
}
}

// FuzzParseTree tests that ParseTree never crashes
func FuzzParseTree(f *testing.F) {
f.Add([]byte("go.sum database tree\n123456789012\nTszzRgjTG6xce+z2AG31kAXYKBgQVtCSCE40HmuwBb0=\n"))
f.Fuzz(func(t *testing.T, text []byte) {
ParseTree(text)
})
}

// FuzzParseRecord tests that ParseRecord never crashes
func FuzzParseRecord(f *testing.F) {
f.Add([]byte("12345\nhello\n\n"))
f.Fuzz(func(t *testing.T, msg []byte) {
Expand Down
24 changes: 24 additions & 0 deletions sumdb/tlog/tile_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package tlog

import (
"testing"
)

// FuzzParseTilePath tests that ParseTilePath never crashes
func FuzzParseTilePath(f *testing.F) {
f.Add("tile/4/0/001")
f.Add("tile/4/0/001.p/5")
f.Add("tile/3/5/x123/x456/078")
f.Add("tile/3/5/x123/x456/078.p/2")
f.Add("tile/1/0/x003/x057/500")
f.Add("tile/3/5/123/456/078")
f.Add("tile/3/-1/123/456/078")
f.Add("tile/1/data/x003/x057/500")
f.Fuzz(func(t *testing.T, path string) {
ParseTilePath(path)
})
}

0 comments on commit 6fff4e6

Please sign in to comment.