[PATCH] D60282: [libFuzzer] Make DataFlow scripts Python3 compatible.
Max Moroz via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 4 12:32:40 PDT 2019
Dor1s created this revision.
Dor1s added reviewers: morehouse, kcc.
Herald added subscribers: Sanitizers, delcypher.
Herald added projects: LLVM, Sanitizers.
Python2 will hit end of life soon: https://pythonclock.org/
This change also makes the integration with OSS-Fuzz a bit simpler:
https://github.com/google/oss-fuzz/issues/1632
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D60282
Files:
lib/fuzzer/scripts/collect_data_flow.py
lib/fuzzer/scripts/merge_data_flow.py
Index: lib/fuzzer/scripts/merge_data_flow.py
===================================================================
--- lib/fuzzer/scripts/merge_data_flow.py
+++ lib/fuzzer/scripts/merge_data_flow.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#===- lib/fuzzer/scripts/merge_data_flow.py ------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Index: lib/fuzzer/scripts/collect_data_flow.py
===================================================================
--- lib/fuzzer/scripts/collect_data_flow.py
+++ lib/fuzzer/scripts/collect_data_flow.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#===- lib/fuzzer/scripts/collect_data_flow.py ------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -39,7 +39,9 @@
for root, dirs, files in os.walk(corpus_dir):
for f in files:
path = os.path.join(root, f)
- sha1 = hashlib.sha1(open(path).read()).hexdigest()
+ with open(path, 'rb') as fh:
+ data = fh.read()
+ sha1 = hashlib.sha1(data).hexdigest()
output = os.path.join(output_dir, sha1)
subprocess.call([self, exe, path, output])
functions_txt = open(os.path.join(output_dir, "functions.txt"), "w")
@@ -55,11 +57,11 @@
q = [[0, size]]
tmpdir = tempfile.mkdtemp(prefix="libfuzzer-tmp-")
atexit.register(cleanup, tmpdir)
- print "tmpdir: ", tmpdir
+ print("tmpdir: ", tmpdir)
outputs = []
while len(q):
r = q.pop()
- print "******* Trying: ", r
+ print("******* Trying: ", r)
tmpfile = os.path.join(tmpdir, str(r[0]) + "-" + str(r[1]))
ret = subprocess.call([exe, str(r[0]), str(r[1]), inp, tmpfile])
if ret and r[1] - r[0] >= 2:
@@ -67,7 +69,7 @@
q.append([(r[1] + r[0]) / 2, r[1]])
else:
outputs.append(tmpfile)
- print "******* Success: ", r
+ print("******* Success: ", r)
f = sys.stdout
if len(argv) >= 4:
f = open(argv[3], "w")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60282.193765.patch
Type: text/x-patch
Size: 2032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190404/4be633b0/attachment.bin>
More information about the llvm-commits
mailing list