Fix API check for length of external arrays.

R=jkummerow@chromium.org
BUG=chromium:148896
TEST=cctest/test-api/ExternalArrayLimits

Review URL: https://codereview.chromium.org/10914257

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12495 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1d1adaf9
......@@ -3404,7 +3404,7 @@ void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) {
ON_BAILOUT(isolate, "v8::SetElementsToPixelData()", return);
ENTER_V8(isolate);
i::HandleScope scope(isolate);
if (!ApiCheck(length <= i::ExternalPixelArray::kMaxLength,
if (!ApiCheck(length >= 0 && length <= i::ExternalPixelArray::kMaxLength,
"v8::Object::SetIndexedPropertiesToPixelData()",
"length exceeds max acceptable value")) {
return;
......@@ -3460,7 +3460,7 @@ void v8::Object::SetIndexedPropertiesToExternalArrayData(
ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return);
ENTER_V8(isolate);
i::HandleScope scope(isolate);
if (!ApiCheck(length <= i::ExternalArray::kMaxLength,
if (!ApiCheck(length >= 0 && length <= i::ExternalArray::kMaxLength,
"v8::Object::SetIndexedPropertiesToExternalArrayData()",
"length exceeds max acceptable value")) {
return;
......
......@@ -14039,6 +14039,41 @@ THREADED_TEST(ExternalArrayInfo) {
}
void ExternalArrayLimitTestHelper(v8::ExternalArrayType array_type, int size) {
v8::Handle<v8::Object> obj = v8::Object::New();
v8::V8::SetFatalErrorHandler(StoringErrorCallback);
last_location = last_message = NULL;
obj->SetIndexedPropertiesToExternalArrayData(NULL, array_type, size);
CHECK(!obj->HasIndexedPropertiesInExternalArrayData());
CHECK_NE(NULL, last_location);
CHECK_NE(NULL, last_message);
}
TEST(ExternalArrayLimits) {
v8::HandleScope scope;
LocalContext context;
ExternalArrayLimitTestHelper(v8::kExternalByteArray, 0x40000000);
ExternalArrayLimitTestHelper(v8::kExternalByteArray, 0xffffffff);
ExternalArrayLimitTestHelper(v8::kExternalUnsignedByteArray, 0x40000000);
ExternalArrayLimitTestHelper(v8::kExternalUnsignedByteArray, 0xffffffff);
ExternalArrayLimitTestHelper(v8::kExternalShortArray, 0x40000000);
ExternalArrayLimitTestHelper(v8::kExternalShortArray, 0xffffffff);
ExternalArrayLimitTestHelper(v8::kExternalUnsignedShortArray, 0x40000000);
ExternalArrayLimitTestHelper(v8::kExternalUnsignedShortArray, 0xffffffff);
ExternalArrayLimitTestHelper(v8::kExternalIntArray, 0x40000000);
ExternalArrayLimitTestHelper(v8::kExternalIntArray, 0xffffffff);
ExternalArrayLimitTestHelper(v8::kExternalUnsignedIntArray, 0x40000000);
ExternalArrayLimitTestHelper(v8::kExternalUnsignedIntArray, 0xffffffff);
ExternalArrayLimitTestHelper(v8::kExternalFloatArray, 0x40000000);
ExternalArrayLimitTestHelper(v8::kExternalFloatArray, 0xffffffff);
ExternalArrayLimitTestHelper(v8::kExternalDoubleArray, 0x40000000);
ExternalArrayLimitTestHelper(v8::kExternalDoubleArray, 0xffffffff);
ExternalArrayLimitTestHelper(v8::kExternalPixelArray, 0x40000000);
ExternalArrayLimitTestHelper(v8::kExternalPixelArray, 0xffffffff);
}
THREADED_TEST(ScriptContextDependence) {
v8::HandleScope scope;
LocalContext c1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment