Skip to content

drcov parser robustness  #147

@patateqbool

Description

@patateqbool

Hi there!

I’ve been playing with TCG plugin for AFL++ QEMU gerenating drcov files and it appears sometime the column path is empty

Columns: id, base, end, entry, path
0, 0x7fff8000, 0x10007fff8000, 0x0,
1, 0x555555554000, 0x555555d74000, 0x0, /opt/aflplusplus/afl-qemu-trace

I’m not really sure if drcov path column can be empty, but this breaks the drcov parser with the following trace:

Traceback (most recent call last):
  File "/Users/patate/Library/Application Support/Binary Ninja/repositories/community/plugins/gaasedelen_lighthouse/plugins/lighthouse/reader/parsers/drcov.py", line 536, in <module>
    x = DrcovData(argv[1])
        ^^^^^^^^^^^^^^^^^^
  File "/Users/patate/Library/Application Support/Binary Ninja/repositories/community/plugins/gaasedelen_lighthouse/plugins/lighthouse/reader/parsers/drcov.py", line 53, in __init__
    self._parse()
  File "/Users/patate/Library/Application Support/Binary Ninja/repositories/community/plugins/gaasedelen_lighthouse/plugins/lighthouse/reader/parsers/drcov.py", line 133, in _parse
    self._parse_module_table(f)
  File "/Users/patate/Library/Application Support/Binary Ninja/repositories/community/plugins/gaasedelen_lighthouse/plugins/lighthouse/reader/parsers/drcov.py", line 163, in _parse_module_table
    self._parse_module_table_modules(f)
  File "/Users/patate/Library/Application Support/Binary Ninja/repositories/community/plugins/gaasedelen_lighthouse/plugins/lighthouse/reader/parsers/drcov.py", line 276, in _parse_module_table_modules
    module = DrcovModule(f.readline().decode('utf-8').strip(), self.module_table_version)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/patate/Library/Application Support/Binary Ninja/repositories/community/plugins/gaasedelen_lighthouse/plugins/lighthouse/reader/parsers/drcov.py", line 382, in __init__
    self._parse_module(module_data, version)
  File "/Users/patate/Library/Application Support/Binary Ninja/repositories/community/plugins/gaasedelen_lighthouse/plugins/lighthouse/reader/parsers/drcov.py", line 409, in _parse_module
    self._parse_module_v2(data)
  File "/Users/patate/Library/Application Support/Binary Ninja/repositories/community/plugins/gaasedelen_lighthouse/plugins/lighthouse/reader/parsers/drcov.py", line 435, in _parse_module_v2
    self.entry     = int(data[3], 16)
                     ^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 16: '0x0,'

Changing this line to

        #data = module_line.split(", ")
        data = [element.strip() for element in module_line.split(",")]

Allow to support empty path.

I can raise a PR if the proposed fix works for you

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions