Skip to content

Commit

Permalink
Resolve the situation where the function name is bytes (#2367)
Browse files Browse the repository at this point in the history
fix error:
 if function.name.endswith('_chk'):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: endswith first arg must be bytes or a tuple of bytes, not str

Co-authored-by: Ajin Abraham <[email protected]>
  • Loading branch information
ohyeah521 and ajinabraham authored Mar 24, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent ccfedc0 commit 6bce5a2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion mobsf/StaticAnalyzer/views/common/binary/elf.py
Original file line number Diff line number Diff line change
@@ -290,7 +290,14 @@ def is_symbols_stripped(self):
def fortify(self):
fortified_funcs = []
for function in self.elf.symbols:
if function.name.endswith('_chk'):
if isinstance(function.name, bytes):
try:
function_name = function.name.decode('utf-8')
except UnicodeDecodeError:
function_name = function.name.decode('utf-8', 'replace')
else:
function_name = function.name
if function_name.endswith('_chk'):
fortified_funcs.append(function.name)
return fortified_funcs

0 comments on commit 6bce5a2

Please sign in to comment.