MCPcopy
hub / github.com/tinylib/msgp / FuzzReadBytes

Function FuzzReadBytes

msgp/fuzz_test.go:144–198  ·  view source on GitHub ↗

Test all byte reading functions with fuzzing inputs. Since we are reading bytes memory allocations should be well controlled.

(f *testing.F)

Source from the content-addressed store, hash-verified

142// Test all byte reading functions with fuzzing inputs.
143// Since we are reading bytes memory allocations should be well controlled.
144func FuzzReadBytes(f *testing.F) {
145 addFuzzDataFromZip(f, "testdata/FuzzCorpus.zip")
146
147 f.Fuzz(func(t *testing.T, data []byte) {
148 if len(data) == 0 || len(data) > 1<<20 {
149 return
150 }
151 var tmp5 [5]byte
152
153 ReadArrayHeaderBytes(data)
154 ReadBoolBytes(data)
155 ReadByteBytes(data)
156 ReadBytesBytes(data, tmp5[:])
157 ReadBytesZC(data)
158 ReadComplex128Bytes(data)
159 ReadComplex64Bytes(data)
160 ReadDurationBytes(data)
161 ReadExactBytes(data, tmp5[:])
162 ReadExtensionBytes(data, testExt{})
163 ReadFloat32Bytes(data)
164 ReadFloat64Bytes(data)
165 ReadInt8Bytes(data)
166 ReadInt16Bytes(data)
167 ReadInt32Bytes(data)
168 ReadInt64Bytes(data)
169 ReadIntBytes(data)
170 ReadIntfBytes(data)
171 ReadJSONNumberBytes(data)
172 ReadMapHeaderBytes(data)
173 ReadMapKeyZC(data)
174 ReadMapStrIntfBytes(data, map[string]any{})
175 ReadNilBytes(data)
176 ReadStringBytes(data)
177 ReadStringAsBytes(data, tmp5[:])
178 ReadStringBytes(data)
179 ReadStringZC(data)
180 ReadTimeBytes(data)
181 ReadTimeUTCBytes(data)
182 ReadUint8Bytes(data)
183 ReadUint16Bytes(data)
184 ReadUint32Bytes(data)
185 ReadUint64Bytes(data)
186 ReadUintBytes(data)
187 UnmarshalAsJSON(io.Discard, data)
188 iter, errfn := ReadArrayBytes(data, ReadIntBytes)
189 for range iter {
190 }
191 errfn()
192 iter2, errfn2 := ReadMapBytes(data, ReadStringBytes, ReadUint64Bytes)
193 for range iter2 {
194 }
195 errfn2()
196 Skip(data)
197 })
198}
199
200type testExt struct{}
201

Callers

nothing calls this directly

Calls 15

addFuzzDataFromZipFunction · 0.85
ReadArrayHeaderBytesFunction · 0.85
ReadBoolBytesFunction · 0.85
ReadByteBytesFunction · 0.85
ReadBytesBytesFunction · 0.85
ReadBytesZCFunction · 0.85
ReadComplex128BytesFunction · 0.85
ReadComplex64BytesFunction · 0.85
ReadDurationBytesFunction · 0.85
ReadExactBytesFunction · 0.85
ReadExtensionBytesFunction · 0.85
ReadFloat32BytesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…