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

Loading DWARF fails #454

Open
JuliusNmn opened this issue Jan 15, 2024 · 0 comments
Open

Loading DWARF fails #454

JuliusNmn opened this issue Jan 15, 2024 · 0 comments

Comments

@JuliusNmn
Copy link

Description

I can't load debug info from a binary.
file: CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_cpy_72a.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped
I get the following stack trace:

Python 3.11.6 (main, Oct  8 2023, 05:06:43) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cle
>>> cle.Loader("/home/julius/Documents/ML/C/testcases/CWE121_Stack_Based_Buffer_Overflow/s01/CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_cpy_72a.o", load_debug_info=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/julius/Documents/ML/venv/lib/python3.11/site-packages/cle/loader.py", line 188, in __init__
    self.initial_load_objects = self._internal_load(
                                ^^^^^^^^^^^^^^^^^^^^
  File "/home/julius/Documents/ML/venv/lib/python3.11/site-packages/cle/loader.py", line 782, in _internal_load
    obj = self._load_object_isolated(main_spec)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/julius/Documents/ML/venv/lib/python3.11/site-packages/cle/loader.py", line 985, in _load_object_isolated
    result = backend_cls(binary, binary_stream, is_main_bin=self._main_object is None, loader=self, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/julius/Documents/ML/venv/lib/python3.11/site-packages/cle/backends/elf/elf.py", line 208, in __init__
    self._load_exception_handling(dwarf)
  File "/home/julius/Documents/ML/venv/lib/python3.11/site-packages/cle/backends/elf/elf.py", line 620, in _load_exception_handling
    lsda_exception_table = lsda.parse_lsda(entry.lsda_pointer, file_offset)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/julius/Documents/ML/venv/lib/python3.11/site-packages/cle/backends/elf/lsda.py", line 89, in parse_lsda
    header = self._parse_lsda_header()
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/julius/Documents/ML/venv/lib/python3.11/site-packages/cle/backends/elf/lsda.py", line 107, in _parse_lsda_header
    lpstart = struct_parse(Struct("dummy", self._formats[base_encoding]("LPStart")), self.stream)["LPStart"]
                                           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 5
>>> cle.__version__
'9.2.84'
>>> 

Loader works fine if i set load_debug_info=False.

Steps to reproduce the bug

import the attached binary with load_debug_info=True

import cle
cle.Loader("CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_cpy_72a.o", load_debug_info=True)

Environment

Python 3.11.6 (main, Oct 8 2023, 05:06:43) [GCC 13.2.0] on linux

Additional context

CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_cpy_72a.zip

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

No branches or pull requests

1 participant