Skip to content

Commit 6bce5a2

Browse files
Resolve the situation where the function name is bytes (#2367)
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 <ajin25@gmail.com>
1 parent ccfedc0 commit 6bce5a2

File tree

1 file changed

+8
-1
lines changed
  • mobsf/StaticAnalyzer/views/common/binary

1 file changed

+8
-1
lines changed

mobsf/StaticAnalyzer/views/common/binary/elf.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,14 @@ def is_symbols_stripped(self):
290290
def fortify(self):
291291
fortified_funcs = []
292292
for function in self.elf.symbols:
293-
if function.name.endswith('_chk'):
293+
if isinstance(function.name, bytes):
294+
try:
295+
function_name = function.name.decode('utf-8')
296+
except UnicodeDecodeError:
297+
function_name = function.name.decode('utf-8', 'replace')
298+
else:
299+
function_name = function.name
300+
if function_name.endswith('_chk'):
294301
fortified_funcs.append(function.name)
295302
return fortified_funcs
296303

0 commit comments

Comments
 (0)