Skip to content
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

fix: Rare arithmetic overflow crash in MPIHasher #246

Merged
merged 1 commit into from
Jan 16, 2024

Conversation

einsteinx2
Copy link
Contributor

Summary

There is an extremely rare case where a specific string could cause an overflow error when calling MPIHasher.hashString() due to not using the overflow addition operator. I've changed the code from a regular addition to overflow addition which matches the original Objective-C logic and was the intended behavior.

Testing Plan

Due to the nature of this hash function I was unable to write a unit test to reproduce the bug, but I reproduced it manually by setting var hash: Int32 = Int32.max to confirm that it was hypothetically possible and that switching to the overflow addition operator fixes the issue.

Screenshot 2024-01-16 at 2 09 06 PM

Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)

Copy link
Contributor

@BrandonStalnaker BrandonStalnaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@einsteinx2 einsteinx2 merged commit 65fad25 into development Jan 16, 2024
11 checks passed
mparticle-automation added a commit that referenced this pull request Jan 16, 2024
# [8.18.0](v8.17.0...v8.18.0) (2024-01-16)

### Bug Fixes

* Rare arithmetic overflow crash in MPIHasher ([#246](#246)) ([65fad25](65fad25))

### Features

* Identity API response caching ([#244](#244)) ([9eaa0ea](9eaa0ea))
@mparticle-automation
Copy link
Contributor

🎉 This PR is included in version 8.18.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants