mParticle / mparticle-apple-sdk

mParticle Apple SDK
Apache License 2.0
46 stars 66 forks source link

fix: Rare arithmetic overflow crash in MPIHasher #246

Closed einsteinx2 closed 9 months ago

einsteinx2 commented 9 months ago

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)

mparticle-automation commented 9 months ago

:tada: This PR is included in version 8.18.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: