Skip to content

Commit

Permalink
[vm] Censor mirroring of dart:ffi when --enable-ffi=false
Browse files Browse the repository at this point in the history
Updates #37044.

Change-Id: I51b11fe8f326e1f98d86fc674147176afae873a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105327
Commit-Queue: Matthew Dempsky <mdempsky@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
  • Loading branch information
mdempsky authored and commit-bot@chromium.org committed Jun 6, 2019
1 parent 41eea71 commit 3d92a75
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions runtime/lib/mirrors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,23 @@ static RawInstance* CreateClassMirror(const Class& cls,
return CreateMirror(Symbols::_LocalClassMirror(), args);
}

static bool IsCensoredLibrary(const String& url) {
static const char* const censored_libraries[] = {
"dart:_builtin",
"dart:_vmservice",
"dart:vmservice_io",
};
for (const char* censored_library : censored_libraries) {
if (url.Equals(censored_library)) {
return true;
}
}
if (!Api::IsFfiEnabled() && url.Equals(Symbols::DartFfi())) {
return true;
}
return false;
}

static RawInstance* CreateLibraryMirror(Thread* thread, const Library& lib) {
Zone* zone = thread->zone();
ASSERT(!lib.IsNull());
Expand All @@ -340,17 +357,9 @@ static RawInstance* CreateLibraryMirror(Thread* thread, const Library& lib) {
str = lib.name();
args.SetAt(1, str);
str = lib.url();
const char* censored_libraries[] = {
"dart:_builtin",
"dart:_vmservice",
"dart:vmservice_io",
NULL,
};
for (intptr_t i = 0; censored_libraries[i] != NULL; i++) {
if (str.Equals(censored_libraries[i])) {
// Censored library (grumble).
return Instance::null();
}
if (IsCensoredLibrary(str)) {
// Censored library (grumble).
return Instance::null();
}
args.SetAt(2, str);
return CreateMirror(Symbols::_LocalLibraryMirror(), args);
Expand Down

0 comments on commit 3d92a75

Please sign in to comment.