summaryrefslogtreecommitdiff
path: root/tests/format/elf/oob_section_name.py
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-11-25 23:26:53 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-11-25 23:26:53 (GMT)
commit545d0490f6fbb397da66410f534670c52bfcc5da (patch)
treeb6923de79a4b406e51b906b76a737d93ea74b73c /tests/format/elf/oob_section_name.py
parent355a7140932b77d351bc6ddd965608b0011af855 (diff)
Implemented restricted contents and created test cases.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@608 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'tests/format/elf/oob_section_name.py')
-rw-r--r--tests/format/elf/oob_section_name.py36
1 files changed, 30 insertions, 6 deletions
diff --git a/tests/format/elf/oob_section_name.py b/tests/format/elf/oob_section_name.py
index da58e29..8f91efd 100644
--- a/tests/format/elf/oob_section_name.py
+++ b/tests/format/elf/oob_section_name.py
@@ -10,15 +10,39 @@
# lors de l'accès concret, au moment de l'appel à strlen().
-import pychrysalide
-
+from chrysacase import ChrysalideTestCase
from pychrysalide.analysis.contents import FileContent
from pychrysalide.format.elf import ElfFormat
+import os
+import sys
+
+
+class TestNonExistingBinary(ChrysalideTestCase):
+ """TestCase for corrupted ELF binaries with wrong section names."""
+
+ @classmethod
+ def setUpClass(cls):
+
+ super(TestNonExistingBinary, cls).setUpClass()
+
+ cls.log('Compile binary "oob_section_name" if needed...')
+
+ fullname = sys.modules[cls.__module__].__file__
+ dirpath = os.path.dirname(fullname)
+
+ os.system('make -C %s oob_section_name 2>&1 > /dev/null' % dirpath)
+
+
+ def testOOBSectionName(self):
+ """Avoid crashing when dealing with OutOfBound section names."""
-cnt = FileContent("oob_section_name")
+ fullname = sys.modules[self.__class__.__module__].__file__
+ filename = os.path.basename(fullname)
-fmt = ElfFormat(cnt)
+ baselen = len(fullname) - len(filename)
-print(fmt)
+ cnt = FileContent(fullname[:baselen] + 'oob_section_name')
+ self.assertIsNotNone(cnt)
-print(isinstance(fmt, ElfFormat))
+ fmt = ElfFormat(cnt)
+ self.assertIsInstance(fmt, ElfFormat)