Skip to content

Commit ba95180

Browse files
committed
fix afl-cov for python3. python sucks.
1 parent db64d33 commit ba95180

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

afl-cov

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def process_afl_test_cases(cargs):
224224
logr("\n\n++++++ BEGIN - first exec output for CMD: %s" % \
225225
(cargs.coverage_cmd.replace('AFL_FILE', f)),
226226
cov_paths['log_file'], cargs)
227-
for line in out_lines:
227+
for line in out_lines.decode("ascii"):
228228
logr(" %s" % (line), cov_paths['log_file'], cargs)
229229
logr("++++++ END\n", cov_paths['log_file'], cargs)
230230

@@ -619,16 +619,16 @@ def lcov_gen_coverage(cov_paths, cargs):
619619

620620
def log_coverage(out_lines, log_file, cargs):
621621
for line in out_lines:
622-
m = re.search('^\s+(lines\.\..*\:\s.*)', line)
622+
m = re.search('^\s+(lines\.\..*\:\s.*)', line.decode("ascii"))
623623
if m and m.group(1):
624624
logr(" " + m.group(1), log_file, cargs)
625625
else:
626-
m = re.search('^\s+(functions\.\..*\:\s.*)', line)
626+
m = re.search('^\s+(functions\.\..*\:\s.*)', line.decode("ascii"))
627627
if m and m.group(1):
628628
logr(" " + m.group(1), log_file, cargs)
629629
else:
630630
if cargs.enable_branch_coverage:
631-
m = re.search('^\s+(branches\.\..*\:\s.*)', line)
631+
m = re.search('^\s+(branches\.\..*\:\s.*)', line.decode("ascii"))
632632
if m and m.group(1):
633633
logr(" " + m.group(1),
634634
log_file, cargs)
@@ -724,17 +724,17 @@ def run_cmd(cmd, log_file, cargs, collect, aflrun, fn, timeout=None):
724724

725725
if cargs.disable_cmd_redirection or collect == WANT_OUTPUT \
726726
or collect == LOG_ERRORS:
727-
with open(fh.name, 'r', encoding='ISO-8859-1') as f:
727+
with open(fh.name, 'rb') as f:
728728
for line in f:
729-
out.append(line.rstrip('\n'))
729+
out.append(line.rstrip(b'\n'))
730730
os.unlink(fh.name)
731731

732732
if (es != 0) and (collect == LOG_ERRORS or collect == WANT_OUTPUT):
733733
if log_file:
734734
logr(" Non-zero exit status '%d' for CMD: %s" % (es, cmd),
735735
log_file, cargs)
736736
for line in out:
737-
logr(line, log_file, cargs)
737+
logr(line.decode("ascii"), log_file, cargs)
738738
else:
739739
print(" Non-zero exit status '%d' for CMD: %s" % (es, cmd))
740740

@@ -844,13 +844,13 @@ def is_bin_gcov_enabled(binary, cargs):
844844
### run readelf against the binary to see if it contains gcov support
845845
for line in run_cmd("%s -a %s" % (cargs.readelf_path, binary),
846846
False, cargs, WANT_OUTPUT, False, "")[1]:
847-
if ' __gcov' in line:
847+
if b' __gcov' in line:
848848
if cargs.validate_args or cargs.gcov_check or cargs.gcov_check_bin:
849849
print("[+] Binary '%s' is compiled with code coverage support via gcc." % binary)
850850
rv = True
851851
break
852852

853-
if '__llvm_gcov' in line:
853+
if b'__llvm_gcov' in line:
854854
if cargs.validate_args or cargs.gcov_check or cargs.gcov_check_bin:
855855
print("[+] Binary '%s' is compiled with code coverage support via llvm." % binary)
856856
rv = True

0 commit comments

Comments
 (0)