@@ -40,13 +40,16 @@ type CoordinateFuzzingOpts struct {
40
40
Limit int64
41
41
42
42
// MinimizeTimeout is the amount of wall clock time to spend minimizing
43
- // after discovering a crasher. If zero, there will be no time limit.
43
+ // after discovering a crasher. If zero, there will be no time limit. If
44
+ // MinimizeTimeout and MinimizeLimit are both zero, then minimization will
45
+ // be disabled.
44
46
MinimizeTimeout time.Duration
45
47
46
48
// MinimizeLimit is the maximum number of calls to the fuzz function to be
47
- // made while minimizing after finding a crash. If zero, there will be
48
- // no limit. Calls to the fuzz function made when minimizing also count
49
- // toward Limit.
49
+ // made while minimizing after finding a crash. If zero, there will be no
50
+ // limit. Calls to the fuzz function made when minimizing also count toward
51
+ // Limit. If MinimizeTimeout and MinimizeLimit are both zero, then
52
+ // minimization will be disabled.
50
53
MinimizeLimit int64
51
54
52
55
// parallel is the number of worker processes to run in parallel. If zero,
@@ -552,9 +555,10 @@ type coordinator struct {
552
555
// generated values that workers reported as interesting.
553
556
corpus corpus
554
557
555
- // typesAreMinimizable is true if one or more of the types of fuzz function's
556
- // parameters can be minimized.
557
- typesAreMinimizable bool
558
+ // minimizationAllowed is true if one or more of the types of fuzz
559
+ // function's parameters can be minimized, and either the limit or duration
560
+ // for minimization is non-zero.
561
+ minimizationAllowed bool
558
562
559
563
// inputQueue is a queue of inputs that workers should try fuzzing. This is
560
564
// initially populated from the seed corpus and cached inputs. More inputs
@@ -604,10 +608,12 @@ func newCoordinator(opts CoordinateFuzzingOpts) (*coordinator, error) {
604
608
resultC : make (chan fuzzResult ),
605
609
corpus : corpus ,
606
610
}
607
- for _ , t := range opts .Types {
608
- if isMinimizable (t ) {
609
- c .typesAreMinimizable = true
610
- break
611
+ if opts .MinimizeLimit > 0 || opts .MinimizeTimeout > 0 {
612
+ for _ , t := range opts .Types {
613
+ if isMinimizable (t ) {
614
+ c .minimizationAllowed = true
615
+ break
616
+ }
611
617
}
612
618
}
613
619
@@ -736,7 +742,7 @@ func (c *coordinator) queueForMinimization(result fuzzResult, keepCoverage []byt
736
742
// peekMinimizeInput returns the next input that should be sent to workers for
737
743
// minimization.
738
744
func (c * coordinator ) peekMinimizeInput () (fuzzMinimizeInput , bool ) {
739
- if c . opts . Limit > 0 && c . count + c . countWaiting >= c . opts . Limit {
745
+ if ! c . canMinimize () {
740
746
// Already making the maximum number of calls to the fuzz function.
741
747
// Don't send more inputs right now.
742
748
return fuzzMinimizeInput {}, false
@@ -810,7 +816,7 @@ func (c *coordinator) updateCoverage(newCoverage []byte) int {
810
816
// canMinimize returns whether the coordinator should attempt to find smaller
811
817
// inputs that reproduce a crash or new coverage.
812
818
func (c * coordinator ) canMinimize () bool {
813
- return c .typesAreMinimizable &&
819
+ return c .minimizationAllowed &&
814
820
(c .opts .Limit == 0 || c .count + c .countWaiting < c .opts .Limit )
815
821
}
816
822
0 commit comments