-
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: coerce offset to integer #18215
Conversation
The offset was formerly coerced to a integer and this reimplements that. Fixes nodejs#18208
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 if CI is happy
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, 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; |
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.
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.
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.
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.
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>
Landed in 7a23fc0 |
@BridgeAR There seems to be still no tests for e.g. |
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>
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>
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 this doesn't land cleanly on |
@BridgeAR ... ping ... can you open a backport PR for 8.x? |
The offset was formerly coerced to a integer and this reimplements
that.
Fixes #18208
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
buffer