Skip to content
Permalink
Browse files

Fixed a bug matching with 1.0 big functions with rather small changes

BUG: Functions with the same name, with the same MD-Index with a value > 10.0 were incorrectly always considered to be absolutely equal even when there were small changes (ie: only one line)
  • Loading branch information
joxeankoret committed Jan 22, 2020
1 parent e4106bc commit 44dfc7d31401f94764f1f62f2de626527c7fb29c
Showing with 3 additions and 3 deletions.
  1. +3 −3 diaphora.py
6 diaphora.py 100755 → 100644
@@ -1219,9 +1219,9 @@ def check_ratio(self, ast1, ast2, pseudo1, pseudo2, asm1, asm2, md1, md2):
v4 = 0.0
if md1 == md2 and md1 > 0.0:
# A MD-Index >= 10.0 is somehow rare
if self.relaxed_ratio or md1 > 10.0:
if self.relaxed_ratio and md1 > 10.0:
return 1.0
v4 = min((v1 + v2 + v3 + 3.0) / 4, 1.0)
v4 = min((v1 + v2 + v3 + 3.0) / 5, 1.0)

r = max(v1, v2, v3, v4)
if r == 1.0 and md1 != md2:
@@ -1648,7 +1648,7 @@ def find_same_name(self, choose):
if not should_add or name1 in self.matched1 or name2 in self.matched2:
continue

if float(ratio) == 1.0 or (md1 != 0 and md1 == md2):
if float(ratio) == 1.0 or (self.relaxed_ratio and md1 != 0 and md1 == md2):
self.best_chooser.add_item(CChooser.Item(ea, name, ea2, name, desc, 1, bb1, bb2))
else:
choose.add_item(CChooser.Item(ea, name, ea2, name, desc, ratio, bb1, bb2))

0 comments on commit 44dfc7d

Please sign in to comment.
You can’t perform that action at this time.