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

Unified Diff: runtime/bin/process.cc

Issue 8383037: Improve error handling in the process library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 2 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/main.cc ('k') | runtime/bin/process.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process.cc
diff --git a/runtime/bin/process.cc b/runtime/bin/process.cc
index 484316bdf2061548b57d7514bc187086258ea7c8..8419fdfc2d9d1b3d3bf547a0e014191cefe3285d 100644
--- a/runtime/bin/process.cc
+++ b/runtime/bin/process.cc
@@ -14,9 +14,23 @@ void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) {
intptr_t out;
intptr_t err;
intptr_t exit_event;
- const char* path =
- DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1));
+ Dart_Handle status_handle = Dart_GetNativeArgument(args, 7);
+ Dart_Handle path_handle = Dart_GetNativeArgument(args, 1);
+ // The Dart code verifies that the path implements the String
+ // interface. However, only builtin Strings are handled by
+ // GetStringValue.
+ if (!Dart_IsString(path_handle)) {
+ DartUtils::SetIntegerInstanceField(status_handle, "_errorCode", 0);
+ DartUtils::SetStringInstanceField(
+ status_handle, "_errorMessage", "Path must be a builtin string");
+ Dart_SetReturnValue(args, Dart_NewBoolean(false));
+ Dart_ExitScope();
+ return;
+ }
+ const char* path = DartUtils::GetStringValue(path_handle);
Dart_Handle arguments = Dart_GetNativeArgument(args, 2);
+ // The arguments are copied into a non-extensible array in the
+ // dart code so this should not fail.
ASSERT(Dart_IsArray(arguments));
Dart_Result result = Dart_GetLength(arguments);
ASSERT(Dart_IsValidResult(result));
@@ -26,13 +40,24 @@ void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) {
result = Dart_ArrayGetAt(arguments, i);
ASSERT(Dart_IsValidResult(result));
Dart_Handle arg = Dart_GetResult(result);
+ // The Dart code verifies that the arguments implement the String
+ // interface. However, only builtin Strings are handled by
+ // GetStringValue.
+ if (!Dart_IsString(arg)) {
+ DartUtils::SetIntegerInstanceField(status_handle, "_errorCode", 0);
+ DartUtils::SetStringInstanceField(
+ status_handle, "_errorMessage", "Arguments must be builtin strings");
+ delete[] string_args;
+ Dart_SetReturnValue(args, Dart_NewBoolean(false));
+ Dart_ExitScope();
+ return;
+ }
string_args[i] = const_cast<char *>(DartUtils::GetStringValue(arg));
}
Dart_Handle in_handle = Dart_GetNativeArgument(args, 3);
Dart_Handle out_handle = Dart_GetNativeArgument(args, 4);
Dart_Handle err_handle = Dart_GetNativeArgument(args, 5);
Dart_Handle exit_handle = Dart_GetNativeArgument(args, 6);
- Dart_Handle status_handle = Dart_GetNativeArgument(args, 7);
intptr_t pid = -1;
static const int kMaxChildOsErrorMessageLength = 256;
char os_error_message[kMaxChildOsErrorMessageLength];
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/bin/process.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698