Skip to content

Commit

Permalink
Verify ELF header in SystemHelper.elf_attributes()
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzeman committed Apr 12, 2016
1 parent 31cd0fb commit c32a40a
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,15 @@ def elf_attributes(cls, executable_path=sys.executable):
# Open executable stream
stream = open(executable_path, 'rb')

# Retrieve magic number (header)
magic = stream.read(4)

if magic != b'\x7fELF':
log.warn('Unknown ELF format for %r (magic: %r)', executable_path, magic)
return None, None

stream.seek(0)

# Parse ELF
elf = ELFFile(stream)

Expand Down

0 comments on commit c32a40a

Please sign in to comment.