From 750fe8f51b577ceb54f7b1333ff1f21f5010f69e Mon Sep 17 00:00:00 2001 From: "Frank J. T. Wojcik" Date: Mon, 25 Oct 2021 21:45:26 -0700 Subject: [PATCH] CRITICAL FIX: Not all differentials can cause Diff test failures This is reported bug #199: https://github.com/rurban/smhasher/issues/199 To see this bug in action, apply the following patch (without this fix!): @@ -158,7 +158,7 @@ bool DiffTest ( pfHash hash, int diffbits, int reps, bool dumpCollisions ) reps,testcount,expected); Hash_Seed_init (hash, g_seed); - for(int i = 0; i < reps; i++) + for(int i = 0; i < 0; i++) { if(i % (reps/10) == 0) printf("."); @@ -173,6 +173,10 @@ bool DiffTest ( pfHash hash, int diffbits, int reps, bool dumpCollisions ) bool result = true; + r.rand_p(&k1,sizeof(keytype)); + diffs.push_back(k1); + diffs.push_back(k1); + result &= ProcessDifferentials(diffs,reps,dumpCollisions); return result; --- DifferentialTest.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DifferentialTest.h b/DifferentialTest.h index 81cf10d7..acf75c6c 100644 --- a/DifferentialTest.h +++ b/DifferentialTest.h @@ -65,6 +65,8 @@ bool ProcessDifferentials ( std::vector & diffs, int reps, bool dumpCol if(count > 1) { + result = false; + if(dumpCollisions) { double pct = 100 * (double(count) / double(reps));