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

Unified Diff: runtime/bin/process.cc

Issue 10690160: Guard against integer overflow in process constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | « no previous file | no next file » | 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 d0682e0e3d73b3082006d79894a986aa238470c2..d9dd3d0978794565553bd56b55c84657ccafc973 100644
--- a/runtime/bin/process.cc
+++ b/runtime/bin/process.cc
@@ -12,12 +12,21 @@ static char** ExtractCStringList(Dart_Handle strings,
Dart_Handle status_handle,
const char* error_msg,
intptr_t* length) {
+ static const intptr_t kMaxArgumentListLength = 1024 * 1024;
ASSERT(Dart_IsList(strings));
intptr_t len = 0;
Dart_Handle result = Dart_ListLength(strings, &len);
if (Dart_IsError(result)) {
Dart_PropagateError(result);
}
+ // Protect against user-defined list implementations that can have
+ // arbitrary length.
+ if (len < 0 || len > kMaxArgumentListLength) {
+ DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
+ DartUtils::SetStringField(
+ status_handle, "_errorMessage", "Max argument list length exceeded");
+ return NULL;
+ }
*length = len;
char** string_args = new char*[len];
for (int i = 0; i < len; i++) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698