Skip to content

Commit cb25325

Browse files
committed
add --validate-args
1 parent a19753b commit cb25325

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

afl-cov

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,12 @@ def main():
6767
if cargs.stop_afl:
6868
return not stop_afl(cargs)
6969

70-
if not validate_args(cargs):
70+
if not validate_cargs(cargs):
7171
return exit_failure
7272

73+
if cargs.validate_args:
74+
return exit_success
75+
7376
if cargs.func_search or cargs.line_search:
7477
return not search_cov(cargs)
7578

@@ -175,6 +178,9 @@ def process_afl_test_cases(cargs):
175178
out_lines = run_cmd(cargs.coverage_cmd.replace('AFL_FILE', f),
176179
cov_paths['log_file'], cargs, WANT_OUTPUT)[1]
177180
run_once = True
181+
182+
tot_files += 1
183+
178184
# capture coverage
179185
run_cmd(cargs.lcov_path +
180186
lcov_opts +
@@ -932,6 +938,8 @@ def is_gcov_enabled(binary, cargs):
932938
for line in run_cmd("%s -a %s" % (cargs.readelf_path, binary),
933939
False, cargs, WANT_OUTPUT)[1]:
934940
if ' __gcov' in line:
941+
if cargs.validate_args:
942+
print " Binary '%s' is compiled with code coverage support." % binary
935943
rv = True
936944
break
937945

@@ -977,7 +985,7 @@ def check_requirements(cargs):
977985

978986
return False
979987

980-
def validate_args(cargs):
988+
def validate_cargs(cargs):
981989

982990
if cargs.coverage_cmd:
983991
if 'AFL_FILE' not in cargs.coverage_cmd:
@@ -1245,6 +1253,8 @@ def parse_cmdline():
12451253
p.add_argument("--stop-afl", action='store_true',
12461254
help="Stop all running afl-fuzz instances associated with --afl-fuzzing-dir <dir>",
12471255
default=False)
1256+
p.add_argument("--validate-args", action='store_true',
1257+
help="Validate args and exit", default=False)
12481258
p.add_argument("-v", "--verbose", action='store_true',
12491259
help="Verbose mode", default=False)
12501260
p.add_argument("-V", "--version", action='store_true',

0 commit comments

Comments
 (0)