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

Unified Diff: runtime/bin/loader.cc

Issue 2153203002: Strip the scheme off of uris passed into the native extension loader. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: rmacnak review Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/extensions.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/loader.cc
diff --git a/runtime/bin/loader.cc b/runtime/bin/loader.cc
index f93f3e856c3ae428cc8e80ab83e043e1d2d005fd..938bfec24759643a1a3ab6c1f0bfcec3a129fb44 100644
--- a/runtime/bin/loader.cc
+++ b/runtime/bin/loader.cc
@@ -296,8 +296,15 @@ bool Loader::ProcessResultLocked(Loader* loader, Loader::IOResult* result) {
ASSERT(library_uri != Dart_Null());
Dart_Handle library = Dart_LookupLibrary(library_uri);
ASSERT(!Dart_IsError(library));
- const char* lib_path_str = reinterpret_cast<const char*>(result->payload);
+ const char* lib_uri = reinterpret_cast<const char*>(result->payload);
+ if (strncmp(lib_uri, "http://", 7) == 0 ||
+ strncmp(lib_uri, "https://", 8) == 0) {
+ loader->error_ =
+ Dart_NewApiError("Cannot load native extensions over http: or https:");
+ return false;
+ }
const char* extension_uri = reinterpret_cast<const char*>(result->uri);
+ const char* lib_path = DartUtils::RemoveScheme(lib_uri);
const char* extension_path = DartUtils::RemoveScheme(extension_uri);
if (strchr(extension_path, '/') != NULL ||
(IsWindowsHost() && strchr(extension_path, '\\') != NULL)) {
@@ -306,7 +313,7 @@ bool Loader::ProcessResultLocked(Loader* loader, Loader::IOResult* result) {
extension_path);
return false;
}
- Dart_Handle result = Extensions::LoadExtension(lib_path_str,
+ Dart_Handle result = Extensions::LoadExtension(lib_path,
extension_path,
library);
if (Dart_IsError(result)) {
« no previous file with comments | « runtime/bin/extensions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698