Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drcov parser robustness #147

Open
patateqbool opened this issue Oct 31, 2024 · 0 comments
Open

drcov parser robustness #147

patateqbool opened this issue Oct 31, 2024 · 0 comments

Comments

@patateqbool
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant