Fuzz Reader tests the Reader methods with fuzzing inputs.
(f *testing.F)
| 16 | |
| 17 | // Fuzz Reader tests the Reader methods with fuzzing inputs. |
| 18 | func FuzzReader(f *testing.F) { |
| 19 | addFuzzDataFromZip(f, "testdata/FuzzCorpus.zip") |
| 20 | |
| 21 | f.Fuzz(func(t *testing.T, data []byte) { |
| 22 | if len(data) == 0 || len(data) > 1<<20 { |
| 23 | return |
| 24 | } |
| 25 | var tmp5 [5]byte |
| 26 | r := NewReader(bytes.NewReader(data)) |
| 27 | // Set some rather low limits for the reader to avoid excessive memory usage. |
| 28 | r.SetMaxRecursionDepth(1000) |
| 29 | r.SetMaxElements(10000) |
| 30 | r.SetMaxStringLength(1000) |
| 31 | |
| 32 | reset := func() { |
| 33 | t.Helper() |
| 34 | // Reset the test state if needed |
| 35 | r.Reset(bytes.NewReader(data)) |
| 36 | } |
| 37 | // Uses reset when data is read off the stream. |
| 38 | r.BufferSize() |
| 39 | r.Buffered() |
| 40 | r.CopyNext(io.Discard) |
| 41 | reset() |
| 42 | r.IsNil() |
| 43 | r.NextType() |
| 44 | r.Read(tmp5[:]) |
| 45 | reset() |
| 46 | r.ReadArrayHeader() |
| 47 | reset() |
| 48 | r.ReadBool() |
| 49 | reset() |
| 50 | r.ReadByte() |
| 51 | reset() |
| 52 | r.ReadBytes(tmp5[:]) |
| 53 | reset() |
| 54 | r.ReadComplex128() |
| 55 | reset() |
| 56 | r.ReadComplex64() |
| 57 | reset() |
| 58 | r.ReadDuration() |
| 59 | reset() |
| 60 | r.ReadExactBytes(tmp5[:]) |
| 61 | reset() |
| 62 | r.ReadExtension(testExt{}) |
| 63 | reset() |
| 64 | r.ReadExtensionRaw() |
| 65 | reset() |
| 66 | r.ReadFloat32() |
| 67 | reset() |
| 68 | r.ReadFloat64() |
| 69 | reset() |
| 70 | r.ReadFull(tmp5[:]) |
| 71 | reset() |
| 72 | r.ReadInt() |
| 73 | reset() |
| 74 | r.ReadInt16() |
| 75 | reset() |
nothing calls this directly
no test coverage detected
searching dependent graphs…