clearbluejar / ghidriff

Python Command-Line Ghidra Binary Diffing Engine
https://clearbluejar.github.io/ghidriff/
GNU General Public License v3.0
507 stars 21 forks source link

Division By Zero Traceback #79

Open whoismissing opened 8 months ago

whoismissing commented 8 months ago

I've found it's possible when running ghidriff bin1 bin2 to get a ZeroDivisionError

Traceback (most recent call last):
  File "/home/wsl2/Envs/bd/bin/ghidriff", line 8, in <module>
    sys.exit(main())
  File "/home/wsl2/Envs/bd/lib/python3.10/site-packages/ghidriff/__main__.py", line 87, in main
    pdiff = d.diff_bins(diff[0], diff[1])
  File "/home/wsl2/Envs/bd/lib/python3.10/site-packages/ghidriff/ghidra_diff_engine.py", line 1491, in diff_bins
    match_func_similarity_percent = f'{((matched_funcs_no_changes_len / matched_funcs_len)*100):.4f}%'
ZeroDivisionError: division by zero
clearbluejar commented 8 months ago

ah good find. I'll add a test case for this.

clearbluejar commented 8 months ago

I am having a really difficult time finding a div by zero test case, so I just added some checks around the divisors.

Can you share a copy of the bins that cause this error?