-
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
src: fix 1-byte out-of-bounds write in TwoByteValue #6330
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addaleax
added
the
c++
Issues and PRs that require attention from people who are familiar with C++.
label
Apr 21, 2016
@@ -47,7 +47,8 @@ TwoByteValue::TwoByteValue(Isolate* isolate, Local<Value> value) | |||
return; | |||
|
|||
// Allocate enough space to include the null terminator | |||
size_t len = StringBytes::StorageSize(isolate, string, UCS2) + 1; | |||
size_t len = StringBytes::StorageSize(isolate, string, UCS2) + | |||
sizeof(uint16_t); |
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.
Break right after the '=' and indent the next line by four spaces. Otherwise LGTM and good catch.
LGTM |
Plan 2 bytes instead of 1 byte for the final zero terminator for UTF-16. This is unlikely to cause real-world problems, but that ultimately depends on the `malloc` implementation. The issue can be uncovered by running e.g. `valgrind node -e "Buffer(65536).fill('a'.repeat(4096), 'utf16le')"`
addaleax
force-pushed
the
two-byte-value-off-by-one-write
branch
from
April 21, 2016 19:59
c482574
to
5a322bc
Compare
@addaleax ... wanna get this one landed? I'm cutting v6 RC.4 shortly and would like to get this one in |
Done, landed in a3b5b9c. :) |
addaleax
added a commit
that referenced
this pull request
Apr 22, 2016
Plan 2 bytes instead of 1 byte for the final zero terminator for UTF-16. This is unlikely to cause real-world problems, but that ultimately depends on the `malloc` implementation. The issue can be uncovered by running e.g. `valgrind node -e "Buffer(65536).fill('a'.repeat(4096), 'utf16le')"` Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> PR-URL: #6330
Thank you! |
joelostrowski
pushed a commit
to joelostrowski/node
that referenced
this pull request
Apr 25, 2016
Plan 2 bytes instead of 1 byte for the final zero terminator for UTF-16. This is unlikely to cause real-world problems, but that ultimately depends on the `malloc` implementation. The issue can be uncovered by running e.g. `valgrind node -e "Buffer(65536).fill('a'.repeat(4096), 'utf16le')"` Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> PR-URL: nodejs#6330
jasnell
pushed a commit
that referenced
this pull request
Apr 26, 2016
Plan 2 bytes instead of 1 byte for the final zero terminator for UTF-16. This is unlikely to cause real-world problems, but that ultimately depends on the `malloc` implementation. The issue can be uncovered by running e.g. `valgrind node -e "Buffer(65536).fill('a'.repeat(4096), 'utf16le')"` Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> PR-URL: #6330
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Checklist
Affected core subsystem(s)
src, buffer (
Buffer.fill
is the only place whereTwoByteValue
is being used)Description of change
Plan 2 bytes instead of 1 byte for the final zero terminator for UTF-16. This is unlikely to cause real-world problems, but that ultimately depends on the
malloc
implementation.The issue can be uncovered by running e.g.
valgrind node -e "Buffer(65536).fill('a'.repeat(4096), 'utf16le')"
.CI: https://ci.nodejs.org/job/node-test-commit/3010/