Skip to content

Commit

Permalink
Min table entry size retrieved from struct
Browse files Browse the repository at this point in the history
  • Loading branch information
sevaa committed Apr 16, 2024
1 parent 72d4690 commit 04d4748
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions elftools/elf/elffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,15 +609,15 @@ def _section_offset(self, n):
""" Compute the offset of section #n in the file
"""
shentsize = self['e_shentsize']
if self['e_shoff'] > 0 and shentsize < (0x40 if self.elfclass == 64 else 0x28):
if self['e_shoff'] > 0 and shentsize < self.structs.Elf_Shdr.sizeof():
raise ELFError('Too small e_shentsize: %s' % shentsize)
return self['e_shoff'] + n * shentsize

def _segment_offset(self, n):
""" Compute the offset of segment #n in the file
"""
phentsize = self['e_phentsize']
if self['e_phoff'] > 0 and phentsize < (0x38 if self.elfclass == 64 else 0x20):
if self['e_phoff'] > 0 and phentsize < self.structs.Elf_Phdr.sizeof():
raise ELFError('Too small e_phentsize: %s' % phentsize)
return self['e_phoff'] + n * phentsize

Expand Down

0 comments on commit 04d4748

Please sign in to comment.