-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
src: fix integer overflow in GetNow #22214
Conversation
@@ -617,7 +617,7 @@ Local<Value> Environment::GetNow() { | |||
CHECK_GE(now, timer_base()); | |||
now -= timer_base(); | |||
if (now <= 0xffffffff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this have an U
suffix…?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't matter in this case, right? I thought they were equivalent since this won't fit into an int
and the next type is unsigned int
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I looked it up – without the suffix it is still signed, but it’s a long int
in that case, so we’re probably fine here. :)
This was introduced in #18486 and shouldn't affect versions prior to 10.0.0, correct? |
Landed in 01a160a |
PR-URL: #22214 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
PR-URL: #22214 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
@@ -617,7 +617,7 @@ Local<Value> Environment::GetNow() { | |||
CHECK_GE(now, timer_base()); | |||
now -= timer_base(); | |||
if (now <= 0xffffffff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that the bug still exists for numbers in 2^31 .. 2^32
range?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nkbt This PR fixed the bug for those numbers – all others should remain the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I was not sure if NewFromUnsigned does exactly that
Well, that was stupid... This check used to be for
0xfffffff
which was wrong (onef
too few) so that got fixed, but that change was made based on it being cast to a uint32_t (2**32-1) rather than the correct int32_t. Of course,Integer::New
just happily accepted it despite not actually being able to handle it. Fun stuff...Fixes #22149
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes