MCPcopy
hub / github.com/go-git/go-git / FuzzParser

Function FuzzParser

plumbing/format/packfile/parser_fuzz_test.go:14–39  ·  view source on GitHub ↗
(f *testing.F)

Source from the content-addressed store, hash-verified

12)
13
14func FuzzParser(f *testing.F) {
15 if pf := fixtures.Basic().One().Packfile(); pf != nil {
16 if data, rerr := io.ReadAll(pf); rerr == nil {
17 f.Add(data)
18 }
19 }
20
21 var overflow bytes.Buffer
22 overflow.WriteString("PACK")
23 _ = binary.Write(&overflow, binary.BigEndian, uint32(2))
24 _ = binary.Write(&overflow, binary.BigEndian, uint32(1))
25 overflow.WriteByte(0x90)
26 overflow.Write(bytes.Repeat([]byte{0x80}, 9))
27 sum := sha1.Sum(overflow.Bytes())
28 overflow.Write(sum[:])
29 f.Add(overflow.Bytes())
30
31 f.Fuzz(func(_ *testing.T, data []byte) {
32 scanner := packfile.NewScanner(bytes.NewReader(data))
33 parser, err := packfile.NewParser(scanner)
34 if err != nil {
35 return
36 }
37 _, _ = parser.Parse()
38 })
39}

Callers

nothing calls this directly

Calls 7

ParseMethod · 0.95
NewScannerFunction · 0.92
NewParserFunction · 0.92
SumMethod · 0.80
AddMethod · 0.45
WriteMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…