-
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
buffer: throw range error before truncating write #5605
Conversation
|
||
if (should_assert) { | ||
CHECK_NOT_OOB(offset + memcpy_num >= memcpy_num); | ||
CHECK_NOT_OOB(offset + memcpy_num <= ts_obj_length); | ||
} | ||
CHECK_LE(offset + memcpy_num, ts_obj_length); | ||
|
||
if (offset + sizeof(T) > ts_obj_length) |
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.
Perhaps sizeof(T)
should be replaced here with memcpy_num
for better readability?
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.
Done.
The check to determine whether `noAssert` was set to true and thus whether RangeErrors should be thrown was happening after the write was truncated to the available size of the buffer. These checks now occur in the correct order. Fixes: #5587
@jasnell Correct me if I'm wrong, but this seems to fix a regression that appeared in v5.2.0, and since then these methods did not behave as they should (and as documented). This does reintroduce a throw which wasn't working in 5.2.0 — 5.7.1, though. Should this be a |
LGTM |
hmm... if it's fixing a regression then it's technically not semver-major, you're right. |
LGTM |
The check to determine whether `noAssert` was set to true and thus whether RangeErrors should be thrown was happening after the write was truncated to the available size of the buffer. These checks now occur in the correct order. Fixes: #5587 PR-URL: #5605 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]>
Landed in d3c0d1b |
The check to determine whether `noAssert` was set to true and thus whether RangeErrors should be thrown was happening after the write was truncated to the available size of the buffer. These checks now occur in the correct order. Fixes: #5587 PR-URL: #5605 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]>
Notable changes: * buffer: Now properly throws RangeErrors on out-of-bounds writes (Matt Loring) #5605 - This effects write{Float|Double} when the noAssert option is not used. * timers: - Returned timeout objects now have a Timeout constructor name (Jeremiah Senkpiel) #5793 - Performance of Immediate processing is now ~20-40% faster (Brian White) #4169 * vm: Fixed a contextify regression introduced in v5.9.0 (Ali Ijaz Sheikh) #5800 PR-URL: #5831
Notable changes: * buffer: Now properly throws RangeErrors on out-of-bounds writes (Matt Loring) #5605 - This effects write{Float|Double} when the noAssert option is not used. * timers: - Returned timeout objects now have a Timeout constructor name (Jeremiah Senkpiel) #5793 - Performance of Immediate processing is now ~20-40% faster (Brian White) #4169 * vm: Fixed a contextify regression introduced in v5.9.0 (Ali Ijaz Sheikh) #5800 PR-URL: #5831
Notable changes: * buffer: Now properly throws RangeErrors on out-of-bounds writes (Matt Loring) #5605 - This effects write{Float|Double} when the noAssert option is not used. * timers: - Returned timeout objects now have a Timeout constructor name (Jeremiah Senkpiel) #5793 - Performance of Immediate processing is now ~20-40% faster (Brian White) #4169 * vm: Fixed a contextify regression introduced in v5.9.0 (Ali Ijaz Sheikh) #5800 PR-URL: #5831
Notable changes: * buffer: Now properly throws RangeErrors on out-of-bounds writes (Matt Loring) nodejs#5605 - This effects write{Float|Double} when the noAssert option is not used. * timers: - Returned timeout objects now have a Timeout constructor name (Jeremiah Senkpiel) nodejs#5793 - Performance of Immediate processing is now ~20-40% faster (Brian White) nodejs#4169 * vm: Fixed a contextify regression introduced in v5.9.0 (Ali Ijaz Sheikh) nodejs#5800 PR-URL: nodejs#5831
The check to determine whether
noAssert
was set to true and thuswhether RangeErrors should be thrown was happening after the write was
truncated to the available size of the buffer. These checks now occur in
the correct order.
Fixes: #5587