Skip to content
This repository was archived by the owner on May 13, 2022. It is now read-only.

xxHash sometimes doesn't match the Hash from the C library from Google #16

Closed
illcom94 opened this issue Aug 19, 2015 · 4 comments
Closed

Comments

@illcom94
Copy link

I need to be able to verify an xxHash64 that is being generated by another program. Sometimes the xxHash from this code doesn't match, and when I run the C code downloaded from google, it does.
https://code.google.com/p/xxhash/

Has anyone else had this issue?

@illcom94
Copy link
Author

I stepped through the code along with the C++ code from google and I've found the issue.
xxHash.cs

  1. In ComputeHashInternal() the dataCount variable should be a long instead of an int. On large files, it overflows into negative.
  2. In PostProcess() you have an if statement "if ((remainder.Length % 8) > 4)" this ensures that your code for processing the last 4 bytes of a file will never be hit. It should be changed to " if ((remainder.Length % 8) == 4)".

After these two changes, everything seems to match.

@illcom94
Copy link
Author

After running a few more files I had to make a modification to my #2 fix.
The if statement should be "if ((remainder.Length % 8) >= 4)"

@brandondahler
Copy link
Owner

I'll take a look at as soon as I can. If you know how to submit a pull request with the changes you talked about above, it could significantly help expedite the process.

brandondahler added a commit that referenced this issue Sep 5, 2015
xxHash calculated incorrect valuex when in 64-bit mode and the input satisfies: length % 8 == 4.
xxHash calculated incorrect values when in either mode and the input length was greater than or equal to 2^32 characters in length.

Both of these issues cause breaking changes to any current users of xxHash given the value(s) could satisfy those constraints.
brandondahler added a commit that referenced this issue Sep 5, 2015
xxHash calculated incorrect valuex when in 64-bit mode and the input satisfies: length % 8 == 4.
xxHash calculated incorrect values when in either mode and the input length was greater than or equal to 2^32 characters in length.

Both of these issues cause breaking changes to any current users of xxHash given the value(s) could satisfy those constraints.
brandondahler added a commit that referenced this issue Sep 5, 2015
xxHash calculated incorrect valuex when in 64-bit mode and the input satisfies: length % 8 == 4.
xxHash calculated incorrect values when in either mode and the input length was greater than or equal to 2^31 characters in length.

Both of these issues cause breaking changes to any current users of xxHash given the value(s) could satisfy those constraints.
brandondahler added a commit that referenced this issue Sep 27, 2015
@brandondahler
Copy link
Owner

This issue has been addressed in release 1.8.1.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants