@@ -61,6 +61,11 @@ def main():
61
61
action = 'store_true' ,
62
62
help = 'If true, export coverage information to files in the seed corpus' ,
63
63
)
64
+ parser .add_argument (
65
+ '--valgrind' ,
66
+ action = 'store_true' ,
67
+ help = 'If true, run fuzzing binaries under the valgrind memory error detector. Valgrind 3.14 or later required.' ,
68
+ )
64
69
parser .add_argument (
65
70
'seed_dir' ,
66
71
help = 'The seed corpus to run on (must contain subfolders for each fuzz target).' ,
@@ -129,10 +134,11 @@ def main():
129
134
test_list = test_list_selection ,
130
135
build_dir = config ["environment" ]["BUILDDIR" ],
131
136
export_coverage = args .export_coverage ,
137
+ use_valgrind = args .valgrind ,
132
138
)
133
139
134
140
135
- def run_once (* , corpus , test_list , build_dir , export_coverage ):
141
+ def run_once (* , corpus , test_list , build_dir , export_coverage , use_valgrind ):
136
142
for t in test_list :
137
143
corpus_path = os .path .join (corpus , t )
138
144
if t in FUZZERS_MISSING_CORPORA :
@@ -143,6 +149,8 @@ def run_once(*, corpus, test_list, build_dir, export_coverage):
143
149
'-detect_leaks=0' ,
144
150
corpus_path ,
145
151
]
152
+ if use_valgrind :
153
+ args = ['valgrind' , '--quiet' , '--error-exitcode=1' , '--exit-on-first-error=yes' ] + args
146
154
logging .debug ('Run {} with args {}' .format (t , args ))
147
155
result = subprocess .run (args , stderr = subprocess .PIPE , universal_newlines = True )
148
156
output = result .stderr
0 commit comments