From 8c6b6f1284755851efb5ffce94199d21d345628e Mon Sep 17 00:00:00 2001 From: Connor Imes Date: Thu, 9 Feb 2023 17:08:31 -0500 Subject: [PATCH] disasm: fix pltgottargets handling when no matches are found If you specify sep when splitting a string but the sep value isn't found, you get a list with a single entry that is an empty string. More generally, consecutive delimiters aren't grouped together and are deemed to delimit empty strings. An empty string is an invalid argument for the pltgotmapper function, so filter them out. --- disasm/extern_symbol_process.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disasm/extern_symbol_process.py b/disasm/extern_symbol_process.py index 40c9017..bfbabf1 100644 --- a/disasm/extern_symbol_process.py +++ b/disasm/extern_symbol_process.py @@ -62,7 +62,7 @@ def pltgotmapper(l): items = l.strip().split() dest = int(items[4] if '#' in items else items[2].lstrip('*'), 16) return (int(items[0].rstrip(':'), 16), dest) - pltgottargets = dict(map(pltgotmapper, pltgottargets.strip().split('\n'))) + pltgottargets = dict(map(pltgotmapper, filter(lambda x: len(x) > 0, pltgottargets.strip().split('\n')))) pltgottargets = {e[0]: '<' + pltgotsym[e[1]] + '@plt>' for e in pltgottargets.iteritems() if e[1] in pltgotsym} if len(pltgottargets) == 0: return