Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d44540f

Browse filesBrowse files
trevnorrisMyles Borins
authored andcommitted
buffer: standardize array index check
ParseArrayIndex() was requesting a Uint32Value(), but assigning it to an in32_t. This caused slight differences in error message reported in edge cases of argument parsing. Fixed by getting the IntegerValue() before checking if the value is < 0. Added test of API that was affected. PR-URL: #6084 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 440d117 commit d44540f
Copy full SHA for d44540f

File tree

Expand file treeCollapse file tree

2 files changed

+7
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-1
lines changed
Open diff view settings
Collapse file

‎src/node_internals.h‎

Copy file name to clipboardExpand all lines: src/node_internals.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ inline MUST_USE_RESULT bool ParseArrayIndex(v8::Local<v8::Value> arg,
167167
return true;
168168
}
169169

170-
int32_t tmp_i = arg->Uint32Value();
170+
int64_t tmp_i = arg->IntegerValue();
171171

172172
if (tmp_i < 0)
173173
return false;
Collapse file

‎test/parallel/test-buffer-alloc.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-alloc.js
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,3 +1429,9 @@ assert.equal(Buffer.prototype.parent, undefined);
14291429
assert.equal(Buffer.prototype.offset, undefined);
14301430
assert.equal(SlowBuffer.prototype.parent, undefined);
14311431
assert.equal(SlowBuffer.prototype.offset, undefined);
1432+
1433+
1434+
// Test that ParseArrayIndex handles full uint32
1435+
assert.throws(function() {
1436+
Buffer.from(new ArrayBuffer(0), -1 >>> 0);
1437+
}, /RangeError: 'offset' is out of bounds/);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.