-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exceptions on malformed ELF header contents (#552)
* Exceptions on malformed ELF header contents * Code cleanup * Min table entry size retrieved from struct
- Loading branch information
Showing
5 changed files
with
67 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import unittest | ||
import os | ||
from elftools.common.exceptions import ELFError | ||
from elftools.elf.elffile import ELFFile | ||
|
||
class TestSectionHeaderEntrySizeCheck(unittest.TestCase): | ||
def test_size_check(self): | ||
test_file = os.path.join('test', 'testfiles_for_unittests', 'section_header_bogus_size.elf') | ||
with open(test_file, 'rb') as f: | ||
# This file contains a nonblank section header table and | ||
# claims header table entry size is zero. | ||
with self.assertRaises(ELFError): | ||
elffile = ELFFile(f) | ||
elffile.has_dwarf_info() | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import unittest | ||
import os | ||
from elftools.common.exceptions import ELFError | ||
from elftools.elf.elffile import ELFFile | ||
|
||
class TestSectionSelfLink(unittest.TestCase): | ||
def test_self_link(self): | ||
test_file = os.path.join('test', 'testfiles_for_unittests', 'section_link_to_self.elf') | ||
with open(test_file, 'rb') as f: | ||
# This file contains a SHT_HASH section with sh_link pointing at self. | ||
# The spec says SHT_hash should point at a symtab-type section. | ||
with self.assertRaises(ELFError): | ||
ELFFile(f).has_dwarf_info() | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Binary file not shown.
Binary file not shown.