Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: src/runtime.cc

Issue 561019: Add missing access checks to Object.getOwnPropertyNames. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3233 matching lines...) Expand 10 before | Expand all | Expand 10 after
3244 HandleScope scope; 3244 HandleScope scope;
3245 ASSERT(args.length() == 1); 3245 ASSERT(args.length() == 1);
3246 if (!args[0]->IsJSObject()) { 3246 if (!args[0]->IsJSObject()) {
3247 return Heap::undefined_value(); 3247 return Heap::undefined_value();
3248 } 3248 }
3249 CONVERT_ARG_CHECKED(JSObject, obj, 0); 3249 CONVERT_ARG_CHECKED(JSObject, obj, 0);
3250 3250
3251 // Skip the global proxy as it has no properties and always delegates to the 3251 // Skip the global proxy as it has no properties and always delegates to the
3252 // real global object. 3252 // real global object.
3253 if (obj->IsJSGlobalProxy()) { 3253 if (obj->IsJSGlobalProxy()) {
3254 // Only collect names if access is permitted.
3255 if (obj->IsAccessCheckNeeded() &&
3256 !Top::MayNamedAccess(*obj, Heap::undefined_value(), v8::ACCESS_KEYS)) {
3257 Top::ReportFailedAccessCheck(*obj, v8::ACCESS_KEYS);
3258 return *Factory::NewJSArray(0);
3259 }
3254 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype())); 3260 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype()));
3255 } 3261 }
3256 3262
3257 // Find the number of objects making up this. 3263 // Find the number of objects making up this.
3258 int length = LocalPrototypeChainLength(*obj); 3264 int length = LocalPrototypeChainLength(*obj);
3259 3265
3260 // Find the number of local properties for each of the objects. 3266 // Find the number of local properties for each of the objects.
3261 int* local_property_count = NewArray<int>(length); 3267 int* local_property_count = NewArray<int>(length);
3262 int total_property_count = 0; 3268 int total_property_count = 0;
3263 Handle<JSObject> jsproto = obj; 3269 Handle<JSObject> jsproto = obj;
3264 for (int i = 0; i < length; i++) { 3270 for (int i = 0; i < length; i++) {
3271 // Only collect names if access is permitted.
3272 if (jsproto->IsAccessCheckNeeded() &&
3273 !Top::MayNamedAccess(*jsproto,
3274 Heap::undefined_value(),
3275 v8::ACCESS_KEYS)) {
3276 Top::ReportFailedAccessCheck(*jsproto, v8::ACCESS_KEYS);
3277 return *Factory::NewJSArray(0);
3278 }
3265 int n; 3279 int n;
3266 n = jsproto->NumberOfLocalProperties(static_cast<PropertyAttributes>(NONE)); 3280 n = jsproto->NumberOfLocalProperties(static_cast<PropertyAttributes>(NONE));
3267 local_property_count[i] = n; 3281 local_property_count[i] = n;
3268 total_property_count += n; 3282 total_property_count += n;
3269 if (i < length - 1) { 3283 if (i < length - 1) {
3270 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); 3284 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype()));
3271 } 3285 }
3272 } 3286 }
3273 3287
3274 // Allocate an array with storage for all the property names. 3288 // Allocate an array with storage for all the property names.
(...skipping 4893 matching lines...) Expand 10 before | Expand all | Expand 10 after
8168 } else { 8182 } else {
8169 // Handle last resort GC and make sure to allow future allocations 8183 // Handle last resort GC and make sure to allow future allocations
8170 // to grow the heap without causing GCs (if possible). 8184 // to grow the heap without causing GCs (if possible).
8171 Counters::gc_last_resort_from_js.Increment(); 8185 Counters::gc_last_resort_from_js.Increment();
8172 Heap::CollectAllGarbage(false); 8186 Heap::CollectAllGarbage(false);
8173 } 8187 }
8174 } 8188 }
8175 8189
8176 8190
8177 } } // namespace v8::internal 8191 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698