Skip to content

Commit 6318e6b

Browse files
core: enable loading light C calltrees (#1894)
* core: enable loading light C calltrees Signed-off-by: David Korczynski <[email protected]> * nit Signed-off-by: David Korczynski <[email protected]> --------- Signed-off-by: David Korczynski <[email protected]>
1 parent 998749b commit 6318e6b

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/fuzz_introspector/data_loader.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,15 @@ def read_fuzzer_data_file_to_profile(
5555

5656
# Must be dictionary
5757
if data_dict_yaml is None or not isinstance(data_dict_yaml, dict):
58-
return None
58+
logger.info('Found no data yaml file')
59+
if os.path.isfile('report.yaml'):
60+
data_dict_yaml = utils.data_file_read_yaml('report.yaml')
61+
if data_dict_yaml is None or not isinstance(data_dict_yaml, dict):
62+
logger.info('Report.yaml is not a valid yaml file')
63+
return None
64+
else:
65+
logger.info('Found no module yaml files')
66+
return None
5967

6068
profile = fuzzer_profile.FuzzerProfile(cfg_file, data_dict_yaml, language)
6169

@@ -123,6 +131,9 @@ def load_all_profiles(
123131
profiles = []
124132
data_files = utils.get_all_files_in_tree_with_regex(
125133
target_folder, "fuzzerLogFile.*\.data$")
134+
data_files.extend(
135+
utils.get_all_files_in_tree_with_regex(target_folder,
136+
"fuzzer-calltree-*"))
126137
target_calltrees = utils.get_all_files_in_tree_with_regex(
127138
target_folder, "targetCalltree.txt$")
128139
logger.info(target_calltrees)

src/fuzz_introspector/frontends/frontend_c.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,10 @@ def function_signature(self):
346346
if child.is_named:
347347
if self.root.field_name_for_child(child_idx) == 'body':
348348
break
349-
function_signature += child.text.decode() + ' '
350-
349+
try:
350+
function_signature += child.text.decode() + ' '
351+
except UnicodeDecodeError:
352+
pass
351353
function_signature = function_signature.replace('\n',
352354
'').replace('\\n', '')
353355
while ' ' in function_signature:

src/fuzz_introspector/frontends/oss_fuzz.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ def process_c_project(target_dir, entrypoint, out):
8787
with open(os.path.join(out, 'fuzzer-calltree-%d' % (idx)),
8888
'w',
8989
encoding='utf-8') as f:
90+
f.write("Call tree\n")
9091
f.write(harness_dict['calltree'])
92+
f.write("====================================")
9193

9294

9395
def process_cpp_project(target_dir, entrypoint, out):

0 commit comments

Comments
 (0)