Skip to content

Commit

Permalink
CRITICAL FIX: Not all differentials can cause Diff test failures
Browse files Browse the repository at this point in the history
This is reported bug #199:  rurban/smhasher#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;
  • Loading branch information
fwojcik committed Oct 26, 2021
1 parent 7ec44b0 commit 38738c4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/DifferentialTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ bool ProcessDifferentials ( std::vector<keytype> & diffs, int reps, bool dumpCol

if(count > 1)
{
result = false;

if(dumpCollisions)
{
double pct = 100 * (double(count) / double(reps));
Expand Down

0 comments on commit 38738c4

Please sign in to comment.