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

Change to address CVE-2016-7202 #2196

Merged
merged 1 commit into from
Dec 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Runtime/Library/JavascriptArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5202,7 +5202,7 @@ namespace Js
((SparseArraySegment<Var>*)seg)->ReverseSegment(recycler);
}

seg->left = ((uint32)length) - (seg->left + seg->length);
seg->left = ((uint32)length) > (seg->left + seg->length) ? ((uint32)length) - (seg->left + seg->length) : 0;

seg->next = prevSeg;
// Make sure size doesn't overlap with next segment.
Expand Down
19 changes: 19 additions & 0 deletions test/Array/Array_TypeConfusion_bugs.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,5 +574,24 @@ var tests = [
assert.areEqual([0x41424344], Array.prototype.slice.call(y));
}
},
{
name: "[MSRC34994,35226] heap overflow in Array.prototype.reverse",
body: function ()
{
var count = 0;
arr = new Array(100);
var desc = Object.getOwnPropertyDescriptor(Array.prototype, 1);
Object.defineProperty(Array.prototype, 1, { get: function () {
count++;
if (count == 1) {
arr.push(null);
}
}});

arr.reverse();
restorePropertyFromDescriptor(Array.prototype, 1, desc);
assert.areEqual(101, arr.length);
}
},
];
testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });