diff options
Diffstat (limited to 'lib/fuzzer/scripts')
-rwxr-xr-x | lib/fuzzer/scripts/collect_data_flow.py | 23 | ||||
-rwxr-xr-x | lib/fuzzer/scripts/merge_data_flow.py | 17 | ||||
-rwxr-xr-x | lib/fuzzer/scripts/unbalanced_allocs.py | 7 |
3 files changed, 25 insertions, 22 deletions
diff --git a/lib/fuzzer/scripts/collect_data_flow.py b/lib/fuzzer/scripts/collect_data_flow.py index 3edff66bb..bd601eb63 100755 --- a/lib/fuzzer/scripts/collect_data_flow.py +++ b/lib/fuzzer/scripts/collect_data_flow.py @@ -1,10 +1,9 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 #===- lib/fuzzer/scripts/collect_data_flow.py ------------------------------===# # -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # #===------------------------------------------------------------------------===# # Runs the data-flow tracer several times on the same input in order to collect @@ -40,7 +39,9 @@ def collect_dataflow_for_corpus(self, exe, corpus_dir, output_dir): 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") @@ -56,19 +57,19 @@ def main(argv): 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: - q.append([r[0], (r[1] + r[0]) / 2]) - q.append([(r[1] + r[0]) / 2, r[1]]) + q.append([r[0], (r[1] + r[0]) // 2]) + 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") diff --git a/lib/fuzzer/scripts/merge_data_flow.py b/lib/fuzzer/scripts/merge_data_flow.py index d2f5081e7..b442b89b7 100755 --- a/lib/fuzzer/scripts/merge_data_flow.py +++ b/lib/fuzzer/scripts/merge_data_flow.py @@ -1,10 +1,9 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 #===- lib/fuzzer/scripts/merge_data_flow.py ------------------------------===# # -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # #===------------------------------------------------------------------------===# # Merge several data flow traces into one. @@ -19,7 +18,7 @@ def Merge(a, b): res = array('b') for i in range(0, len(a)): res.append(ord('1' if a[i] == '1' or b[i] == '1' else '0')) - return res.tostring() + return res.tostring().decode('utf-8') def main(argv): D = {} @@ -30,7 +29,11 @@ def main(argv): else: D[F] = BV; for F in D.keys(): - print("%s %s" % (F, D[F])) + if isinstance(D[F], str): + value = D[F] + else: + value = D[F].decode('utf-8') + print("%s %s" % (F, value)) if __name__ == '__main__': main(sys.argv) diff --git a/lib/fuzzer/scripts/unbalanced_allocs.py b/lib/fuzzer/scripts/unbalanced_allocs.py index 74478ad55..579e481a2 100755 --- a/lib/fuzzer/scripts/unbalanced_allocs.py +++ b/lib/fuzzer/scripts/unbalanced_allocs.py @@ -1,10 +1,9 @@ #!/usr/bin/env python #===- lib/fuzzer/scripts/unbalanced_allocs.py ------------------------------===# # -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # #===------------------------------------------------------------------------===# # |