GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — buffer: fix range checks for slice() by trevnorris · Pull Request #9174 · nodejs/node

Conversation

@trevnorris

@trevnorris trevnorris commented Oct 18, 2016

Copy link
Copy Markdown
Contributor
Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

buffer

Description of change

Using the black magic of Symbol.toPrimitive the numeric value of
start/end can be changed when Uint32Value() is called once
Buffer::Fill() is entered. Allowing the CHECK() to be bypassed.

The bug report was only for "start", but the same can be done with
"end". Perform checks for both in node::Buffer::Fill() to make sure the
issue can't be triggered, even if process.binding is used directly.

Include tests for each case. Along with a check to make sure the last
time the value is accessed returns -1. This should be enough to make
sure Buffer::Fill() is receiving the correct value. Along with two tests
against process.binding directly.

Fixes: #9149

R=@nodejs/buffer

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

deian reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@trevnorris trevnorris added the buffer Issues and PRs related to the buffer subsystem. label Oct 18, 2016
jasnell
jasnell approved these changes Oct 18, 2016
View reviewed changes

@jasnell jasnell left a comment

Copy link
Copy Markdown
Member

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.

LGTM with green CI

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jasnell jasnell added this to the 7.0.0 milestone Oct 18, 2016
mscdex
mscdex reviewed Oct 19, 2016
View reviewed changes
Comment thread test/parallel/test-buffer-fill.js Outdated

@mscdex mscdex Oct 19, 2016

Copy link
Copy Markdown
Contributor

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.

Minor nit: this can be just ctr === 0.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@trevnorris trevnorris Oct 19, 2016 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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.

no. in case the internals change then cntr may be less than 0. if that's the case then the value needs to be updated. which is why i have the followup check below of

assert.ok(elseWasLast,
          'internal API changed, -1 no longer in correct location');

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mscdex

mscdex commented Oct 19, 2016

Copy link
Copy Markdown
Contributor

CI: https://ci.nodejs.org/job/node-test-pull-request/4569/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

fhinkel
fhinkel approved these changes Oct 19, 2016
View reviewed changes
bnoordhuis
bnoordhuis approved these changes Oct 19, 2016
View reviewed changes
@deian

deian commented Oct 19, 2016

Copy link
Copy Markdown
Member

Here is another test that this fixes that would otherwise have triggered the CHECK:

const buf = new Buffer('w00t');

Object.defineProperty(buf, 'length', {
  value: 1337,
  enumerable: true
});
buf.fill('');
jorangreef reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mscdex

mscdex commented Oct 19, 2016

Copy link
Copy Markdown
Contributor

+1 to adding more tests!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Oct 20, 2016

Copy link
Copy Markdown
Member

I'd like to get this landed today to be included in the v7.0.0 RC1. Can we add the additional tests in a separate PR?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trevnorris
buffer: fix range checks for slice()
7bffe23
Using the black magic of Symbol.toPrimitive the numeric value of
start/end can be changed when Uint32Value() is called once
Buffer::Fill() is entered. Allowing the CHECK() to be bypassed.

The bug report was only for "start", but the same can be done with
"end". Perform checks for both in node::Buffer::Fill() to make sure the
issue can't be triggered, even if process.binding is used directly.

Include tests for each case. Along with a check to make sure the last
time the value is accessed returns -1. This should be enough to make
sure Buffer::Fill() is receiving the correct value. Along with two tests
against process.binding directly.

Fixes: nodejs#9149
PR-URL: nodejs#9174
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
@trevnorris
trevnorris force-pushed the fix-9149 branch from 45c3358 to 7bffe23 Compare October 20, 2016 19:44
@trevnorris
trevnorris merged commit 7bffe23 into nodejs:master Oct 20, 2016
jasnell pushed a commit that referenced this pull request Oct 20, 2016
@trevnorris @jasnell
buffer: fix range checks for slice()
60042ca
Using the black magic of Symbol.toPrimitive the numeric value of
start/end can be changed when Uint32Value() is called once
Buffer::Fill() is entered. Allowing the CHECK() to be bypassed.

The bug report was only for "start", but the same can be done with
"end". Perform checks for both in node::Buffer::Fill() to make sure the
issue can't be triggered, even if process.binding is used directly.

Include tests for each case. Along with a check to make sure the last
time the value is accessed returns -1. This should be enough to make
sure Buffer::Fill() is receiving the correct value. Along with two tests
against process.binding directly.

Fixes: #9149
PR-URL: #9174
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
@MylesBorins MylesBorins added lts-watch-v4.x labels Nov 15, 2016
@MylesBorins MylesBorins added land-on-v6.x and removed lts-watch-v6.x labels Dec 20, 2016
MylesBorins pushed a commit that referenced this pull request Dec 20, 2016
@trevnorris @MylesBorins
buffer: fix range checks for slice()
a9d528b
Using the black magic of Symbol.toPrimitive the numeric value of
start/end can be changed when Uint32Value() is called once
Buffer::Fill() is entered. Allowing the CHECK() to be bypassed.

The bug report was only for "start", but the same can be done with
"end". Perform checks for both in node::Buffer::Fill() to make sure the
issue can't be triggered, even if process.binding is used directly.

Include tests for each case. Along with a check to make sure the last
time the value is accessed returns -1. This should be enough to make
sure Buffer::Fill() is receiving the correct value. Along with two tests
against process.binding directly.

Fixes: #9149
PR-URL: #9174
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
@MylesBorins

MylesBorins commented Dec 20, 2016

Copy link
Copy Markdown
Contributor

@trevnorris I've gone ahead and landed this on v6.x. If you would like to see it on v4.x please submit a manual backport. Otherwise could you change the label to dont-land-on-v4.x

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

MylesBorins pushed a commit that referenced this pull request Dec 21, 2016
@trevnorris @MylesBorins
buffer: fix range checks for slice()
4528f49
Using the black magic of Symbol.toPrimitive the numeric value of
start/end can be changed when Uint32Value() is called once
Buffer::Fill() is entered. Allowing the CHECK() to be bypassed.

The bug report was only for "start", but the same can be done with
"end". Perform checks for both in node::Buffer::Fill() to make sure the
issue can't be triggered, even if process.binding is used directly.

Include tests for each case. Along with a check to make sure the last
time the value is accessed returns -1. This should be enough to make
sure Buffer::Fill() is receiving the correct value. Along with two tests
against process.binding directly.

Fixes: #9149
PR-URL: #9174
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Dec 21, 2016
V6.9.3 proposal #10394
Merged
@trevnorris trevnorris mentioned this pull request Dec 22, 2016
async_wrap: clear destroy_ids vector #10400
Merged
3 tasks done
@aliscco aliscco mentioned this pull request Jun 21, 2023
[Snyk] Fix for 1 vulnerabilities aliscco/alisco-node#477
Open
This was referenced Jul 1, 2023
[Snyk] Security upgrade jest from 24.9.0 to 26.0.0 aliscco/alisco-node#622
Open
[Snyk] Security upgrade jest from 24.9.0 to 26.0.0 aliscco/alisco-node#623
Open
This was referenced Jul 8, 2023
[Snyk] Security upgrade jest from 25.5.4 to 26.0.0 leonardoadame/node#129
Open
[Snyk] Security upgrade jest from 25.5.4 to 26.0.0 leonardoadame/node#130
Open
@leonardoadame leonardoadame mentioned this pull request Sep 30, 2023
[Snyk] Security upgrade jest from 24.9.0 to 26.0.0 leonardoadame/node#161
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bnoordhuis bnoordhuis bnoordhuis approved these changes
@jasnell jasnell jasnell approved these changes
+2 more reviewers
@mscdex mscdex mscdex left review comments
@fhinkel fhinkel fhinkel approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

buffer Issues and PRs related to the buffer subsystem.

Projects

None yet

Milestone

7.0.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@trevnorris @mscdex @deian @jasnell @MylesBorins @fhinkel @bnoordhuis
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.