File tree 2 files changed +8
-4
lines changed
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -69,12 +69,12 @@ class UserSuppliedFuzzer {
69
69
// / Executes the target function on 'Size' bytes of 'Data'.
70
70
virtual void TargetFunction (const uint8_t *Data, size_t Size ) = 0;
71
71
// / Mutates 'Size' bytes of data in 'Data' inplace into up to 'MaxSize' bytes,
72
- // / returns the new size of the data.
72
+ // / returns the new size of the data, which should be positive .
73
73
virtual size_t Mutate (uint8_t *Data, size_t Size , size_t MaxSize) {
74
74
return BasicMutate (Data, Size , MaxSize);
75
75
}
76
76
// / Crosses 'Data1' and 'Data2', writes up to 'MaxOutSize' bytes into Out,
77
- // / returns the number of bytes written.
77
+ // / returns the number of bytes written, which should be positive .
78
78
virtual size_t CrossOver (const uint8_t *Data1, size_t Size1,
79
79
const uint8_t *Data2, size_t Size2,
80
80
uint8_t *Out, size_t MaxOutSize) {
Original file line number Diff line number Diff line change @@ -289,7 +289,9 @@ void Fuzzer::MutateAndTestOne(Unit *U) {
289
289
size_t Size = U->size ();
290
290
U->resize (Options.MaxLen );
291
291
size_t NewSize = USF.Mutate (U->data (), Size , U->size ());
292
- assert (NewSize > 0 && NewSize <= (size_t )Options.MaxLen );
292
+ assert (NewSize > 0 && " Mutator returned empty unit" );
293
+ assert (NewSize <= (size_t )Options.MaxLen &&
294
+ " Mutator return overisized unit" );
293
295
U->resize (NewSize);
294
296
RunOneAndUpdateCorpus (*U);
295
297
size_t NumTraceBasedMutations = StopTraceRecording ();
@@ -317,7 +319,9 @@ void Fuzzer::Loop(size_t NumIterations) {
317
319
size_t NewSize = USF.CrossOver (
318
320
Corpus[J1].data (), Corpus[J1].size (), Corpus[J2].data (),
319
321
Corpus[J2].size (), CurrentUnit.data (), CurrentUnit.size ());
320
- assert (NewSize > 0 && NewSize <= (size_t )Options.MaxLen );
322
+ assert (NewSize > 0 && " CrossOver returned empty unit" );
323
+ assert (NewSize <= (size_t )Options.MaxLen &&
324
+ " CrossOver return overisized unit" );
321
325
CurrentUnit.resize (NewSize);
322
326
MutateAndTestOne (&CurrentUnit);
323
327
}
You can’t perform that action at this time.
0 commit comments