aboutsummaryrefslogtreecommitdiff
path: root/infra/cifuzz/fuzz_target.py
diff options
context:
space:
mode:
authorjonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com>2020-10-19 10:10:22 -0700
committerGitHub <noreply@github.com>2020-10-19 10:10:22 -0700
commit8daba1a1a1e6d064e04a760f8c9c788938a3ce83 (patch)
tree2dfdf1a2f93f392f762ebbe4cc84a116b1d30ba8 /infra/cifuzz/fuzz_target.py
parentbca4ff4ee843da1b1d28866e2798a3e28d4657a6 (diff)
downloadoss-fuzz-8daba1a1a1e6d064e04a760f8c9c788938a3ce83.tar.gz
[CIFuzz] Don't assume fuzzer output is ASCII (#4537)
[CIFuzz] Don't assume fuzzer output is ascii This is wrong because the output can be arbitrary. Instead change code that deals with the output to deal with bytes. The testcase, which is derived from the output can be decoded as UTF-8 since it will be a unix path.
Diffstat (limited to 'infra/cifuzz/fuzz_target.py')
-rw-r--r--infra/cifuzz/fuzz_target.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/infra/cifuzz/fuzz_target.py b/infra/cifuzz/fuzz_target.py
index d469d855b..28dd80baa 100644
--- a/infra/cifuzz/fuzz_target.py
+++ b/infra/cifuzz/fuzz_target.py
@@ -145,7 +145,7 @@ class FuzzTarget:
stderr=subprocess.PIPE)
try:
- _, err = process.communicate(timeout=self.duration + BUFFER_TIME)
+ _, stderr = process.communicate(timeout=self.duration + BUFFER_TIME)
except subprocess.TimeoutExpired:
logging.error('Fuzzer %s timed out, ending fuzzing.', self.target_name)
return None, None
@@ -158,13 +158,12 @@ class FuzzTarget:
# Crash was discovered.
logging.info('Fuzzer %s, ended before timeout.', self.target_name)
- err_str = err.decode('ascii')
- test_case = self.get_test_case(err_str)
+ test_case = self.get_test_case(stderr)
if not test_case:
- logging.error('No test case found in stack trace: %s.', err_str)
+ logging.error(b'No test case found in stack trace: %s.', stderr)
return None, None
if self.is_crash_reportable(test_case):
- return test_case, err_str
+ return test_case, stderr
return None, None
def is_reproducible(self, test_case, target_path):
@@ -282,18 +281,18 @@ class FuzzTarget:
logging.info('The crash is reproducible without the current pull request.')
return False
- def get_test_case(self, error_string):
+ def get_test_case(self, error_bytes):
"""Gets the file from a fuzzer run stack trace.
Args:
- error_string: The stack trace string containing the error.
+ error_bytes: The bytes containing the output from the fuzzer.
Returns:
- The error test case or None if not found.
+ The path to the test case or None if not found.
"""
- match = re.search(r'\bTest unit written to \.\/([^\s]+)', error_string)
+ match = re.search(rb'\bTest unit written to \.\/([^\s]+)', error_bytes)
if match:
- return os.path.join(self.out_dir, match.group(1))
+ return os.path.join(self.out_dir, match.group(1).decode('utf-8'))
return None
def get_lastest_build_version(self):