tenable/ghidra_tools

Script error

Closed this issue · 4 comments

Hi,

I get the following error after running the script.
ENV.Variable initialized with API key, Ghidra restarted, python 3.8.3, Windows 11 ...

Traceback (most recent call last):
File "C:\Users\XXXX\ghidra_scripts\NewScript.py", line 569, in
comment = add_explanatory_comment_to_current_function(
File "C:\Users\XXXX\ghidra_scripts\NewScript.py", line 385, in add_explanatory_comment_to_current_function
function_name = function.getName()
AttributeError: 'NoneType' object has no attribute 'getName'

This can happen if you run the script before selecting a function. I'll update it so that it gives you a more meaningful error message. For now, before running the script, try clicking somewhere in the decompiler listing for the function of interest first. This will give the current address and current function variables non-null values.

That helped, thanks. So now the script managed to do most of its job ("This function appears to be performing some cleanup tasks before terminating. First, it initializes...") .
The execution does end with another error though:
Traceback (most recent call last):
File "D:\Downloads\ghidra\ghidra_9.0\Ghidra\Features\Base\ghidra_scripts\g3po.py", line 573, in
apply_renaming_suggestions(comment)
File "D:\Downloads\ghidra\ghidra_9.0\Ghidra\Features\Base\ghidra_scripts\g3po.py", line 539, in apply_renaming_suggestions
old = sanitize_variable_name(old)
File "D:\Downloads\ghidra\ghidra_9.0\Ghidra\Features\Base\ghidra_scripts\g3po.py", line 509, in sanitize_variable_name
name = list(filter(lambda x: len(x) > 0, name.split(" ")))[0]
IndexError: index out of range: 0

alright, the fix has been merged