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

Asserts when encountering invalid files #45

Open
Winterhuman opened this issue Dec 11, 2024 · 0 comments
Open

Asserts when encountering invalid files #45

Winterhuman opened this issue Dec 11, 2024 · 0 comments

Comments

@Winterhuman
Copy link

Winterhuman commented Dec 11, 2024

Version: 0.11-1
systemd: 256.9-1
kernel: 6.12.4-arch1-1

While writing a script to find all dl-opened libraries on a system, I ran into this assert when encountering .py files:

Traceback (most recent call last):
  File "/usr/bin/dlopen-notes", line 142, in <module>
    notes = [read_dlopen_notes(filename) for filename in args.filenames]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/dlopen-notes", line 24, in wrap
    return list(f(*args, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/dlopen-notes", line 29, in read_dlopen_notes
    elffile = ELFFile(open(filename, 'rb'))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/elftools/elf/elffile.py", line 84, in __init__
    self._identify_file()
  File "/usr/lib/python3.12/site-packages/elftools/elf/elffile.py", line 570, in _identify_file
    elf_assert(magic == b'\x7fELF', 'Magic number does not match')
  File "/usr/lib/python3.12/site-packages/elftools/common/utils.py", line 80, in elf_assert
    _assert_with_exception(cond, msg, ELFError)
  File "/usr/lib/python3.12/site-packages/elftools/common/utils.py", line 143, in _assert_with_exception
    raise exception_type(msg)
elftools.common.exceptions.ELFError: Magic number does not match

Ideally, invalid & non-existent files (& directories) wouldn't cause asserts like this.

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

No branches or pull requests

1 participant