-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean that the bug still exists for numbers in There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I was not sure if NewFromUnsigned does exactly that |
||
return Integer::New(isolate(), static_cast<uint32_t>(now)); | ||
return Integer::NewFromUnsigned(isolate(), static_cast<uint32_t>(now)); | ||
else | ||
return Number::New(isolate(), static_cast<double>(now)); | ||
} | ||
|
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 isunsigned 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. :)