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: coerce offset to integer #18215

Closed
wants to merge 1 commit into from

Conversation

BridgeAR
Copy link
Member

The offset was formerly coerced to a integer and this reimplements
that.

Fixes #18208

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

buffer

The offset was formerly coerced to a integer and this reimplements
that.

Fixes nodejs#18208
@nodejs-github-bot nodejs-github-bot added the buffer Issues and PRs related to the buffer subsystem. label Jan 17, 2018
Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if CI is happy

@BridgeAR
Copy link
Member Author

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks. Maybe change the commit title to buffer: coerce offset to uint32.

@@ -1272,25 +1272,29 @@ function toFloat(x) {


Buffer.prototype.readDoubleBE = function(offset, noAssert) {
offset = offset >>> 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... I'd almost prefer to make this an error rather than coerce. If someone just happens to pass in 4294967296 as the offset, they're going to get unexpected results otherwise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer that as well but all other functions right now coerce the numbers to uint32. I will open a separate PR to change that for all functions.

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 19, 2018
BridgeAR added a commit to BridgeAR/node that referenced this pull request Jan 24, 2018
The offset was formerly coerced to a integer and this reimplements
that.

PR-URL: nodejs#18215
Fixes: nodejs#18208
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@BridgeAR
Copy link
Member Author

Landed in 7a23fc0

@ChALkeR
Copy link
Member

ChALkeR commented Jan 29, 2018

@BridgeAR There seems to be still no tests for e.g. readDoubleLE() (without offset parameter).

MylesBorins pushed a commit that referenced this pull request Mar 6, 2018
The offset was formerly coerced to a integer and this reimplements
that.

PR-URL: #18215
Fixes: #18208
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@MylesBorins MylesBorins mentioned this pull request Mar 6, 2018
MylesBorins pushed a commit that referenced this pull request Mar 6, 2018
The offset was formerly coerced to a integer and this reimplements
that.

PR-URL: #18215
Fixes: #18208
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@addaleax addaleax removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 7, 2018
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
The offset was formerly coerced to a integer and this reimplements
that.

PR-URL: nodejs#18215
Fixes: nodejs#18208
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@codebytere
Copy link
Member

@BridgeAR this doesn't land cleanly on v8.x, could you potentially backport it or add a don't land label otherwise?

@jasnell
Copy link
Member

jasnell commented Aug 17, 2018

@BridgeAR ... ping ... can you open a backport PR for 8.x?

@BridgeAR BridgeAR deleted the fix-readdouble branch April 1, 2019 23:38
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.

Floating point value decoded incorrectly by buf.readDoubleBE()
10 participants