Skip to content

RUBY-3435 Don't overflow the 4-bytes allotted to an ObjectID's timestamp portion#327

Merged
jamis merged 4 commits intomongodb:masterfrom
jamis:ruby-3435
Apr 8, 2024
Merged

RUBY-3435 Don't overflow the 4-bytes allotted to an ObjectID's timestamp portion#327
jamis merged 4 commits intomongodb:masterfrom
jamis:ruby-3435

Conversation

@jamis
Copy link
Contributor

@jamis jamis commented Apr 5, 2024

This PR ensures that the timestamp is (1) treated as an unsigned integer, to allow the largest possible value there, and (2) truncated to 32 bits (4 bytes) if it ever grows larger than that. This avoids a RangeError that occurs when trying to convert a Bignum to a 32-bit integer internally.

@jamis jamis requested a review from comandeo-mongo April 5, 2024 17:45
@johnnyshields
Copy link
Contributor

I've run this in my test suite and confirmed that it fixes the bug. Thank you!

@jamis jamis merged commit 79d5aed into mongodb:master Apr 8, 2024
@jamis jamis deleted the ruby-3435 branch April 8, 2024 14:37
@johnnyshields
Copy link
Contributor

@jamis this is running in production for us now FYI 🎉

@jamis
Copy link
Contributor Author

jamis commented Apr 18, 2024

Wonderful, thanks for the confirmation, @johnnyshields. We'll get it officially released soon.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants