From 5533fd4c59c0e4560cbc979a7174e1f788d00ba9 Mon Sep 17 00:00:00 2001 From: gcmoreira Date: Fri, 3 Feb 2017 00:47:30 +1100 Subject: [PATCH] Fix parsing string table (#134) If for any reason parse_cstring_from_stream() cannot get a string in the given offset, it'll return None causing the following line raises an exception when it tries to get the decoded ascii string from the None object. --- elftools/elf/sections.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elftools/elf/sections.py b/elftools/elf/sections.py index 99550ac..1bc1715 100644 --- a/elftools/elf/sections.py +++ b/elftools/elf/sections.py @@ -71,7 +71,7 @@ class StringTableSection(Section): """ table_offset = self['sh_offset'] s = parse_cstring_from_stream(self.stream, table_offset + offset) - return s.decode('ascii') + return s.decode('ascii') if s else '' class SymbolTableSection(Section): -- 2.30.2