Skip to content
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

Closed
wants to merge 1 commit into from
Closed

buffer: throw range error before truncating write #5605

wants to merge 1 commit into from

Conversation

matthewloring
Copy link

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

@ChALkeR ChALkeR added the buffer Issues and PRs related to the buffer subsystem. label Mar 8, 2016

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)
Copy link
Member

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?

Copy link
Author

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 jasnell added error-handling semver-major PRs that contain breaking changes and should be released in the next major version. labels Mar 8, 2016
@mscdex
Copy link
Contributor

mscdex commented Mar 8, 2016

@ChALkeR
Copy link
Member

ChALkeR commented Mar 9, 2016

@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 semver-major or not?

@trevnorris
Copy link
Contributor

LGTM

@jasnell
Copy link
Member

jasnell commented Mar 22, 2016

hmm... if it's fixing a regression then it's technically not semver-major, you're right.

@jasnell jasnell added dont-land-on-v4.x and removed semver-major PRs that contain breaking changes and should be released in the next major version. labels Mar 22, 2016
@jasnell
Copy link
Member

jasnell commented Mar 22, 2016

LGTM

@jasnell
Copy link
Member

jasnell commented Mar 22, 2016

jasnell pushed a commit that referenced this pull request Mar 22, 2016
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]>
@jasnell
Copy link
Member

jasnell commented Mar 22, 2016

Landed in d3c0d1b

@jasnell jasnell closed this Mar 22, 2016
Fishrock123 pushed a commit that referenced this pull request Mar 22, 2016
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]>
Fishrock123 added a commit that referenced this pull request Mar 23, 2016
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
Fishrock123 added a commit that referenced this pull request Mar 23, 2016
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
Fishrock123 added a commit that referenced this pull request Mar 23, 2016
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
Fishrock123 added a commit to Fishrock123/node that referenced this pull request Mar 24, 2016
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
@matthewloring matthewloring deleted the buffer-oob branch October 20, 2016 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants