2 Test that elftools does not fail to load corrupted ELF files
7 from elftools
.elf
.elffile
import ELFFile
8 from elftools
.common
.exceptions
import ELFParseError
11 class TestCorruptFile(unittest
.TestCase
):
12 def test_elffile_init(self
):
13 """ Test that ELFFile does not crash when parsing an ELF file with corrupt e_shoff and/or e_shnum
15 filepath
= os
.path
.join('test', 'testfiles_for_unittests', 'corrupt_sh.elf')
16 with
open(filepath
, 'rb') as f
:
24 self
.assertIsInstance(elf
, ELFFile
, "ELFFile initialization should have detected the out of bounds read")
27 if __name__
== '__main__':