New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zlib: fix Adler32 implementation #301

Merged
merged 2 commits into from Sep 17, 2017

Conversation

Projects
None yet
2 participants
@frabar666
Contributor

frabar666 commented Sep 17, 2017

ZlibStream's Adler32 routine sometime returns incorrect results, as @ied206 noticed in #298.
This fixes #298 by using uint instead of int.

There are no unit tests, because the implementation is internal.
PHP's short test cases are OK, but they were already OK before.

My gut says the issue was due to the % operator not behaving as expected for negative ints, so I tested a 5000-byte 0xFF sequence (to approach the overflow limit at 5552). It exhibits the same pattern as #298, 1st and 5th-8th digits match, but 2nd-4th digits are different: previous implementation returned 0x53e07596, new one returns 0x54b27596 (same as an online Adler32 calculator).

frabar666 and others added some commits Sep 17, 2017

@adamhathcock

This comment has been minimized.

Show comment
Hide comment
@adamhathcock

adamhathcock Sep 17, 2017

Owner

Thanks for this!

Owner

adamhathcock commented Sep 17, 2017

Thanks for this!

@adamhathcock adamhathcock merged commit 7064cda into adamhathcock:master Sep 17, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@frabar666 frabar666 deleted the frabar666:fix-adler32 branch Sep 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment