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

Unified Diff: runtime/bin/file.cc

Issue 10411053: Finish file 'fuzzer' and fix issues. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typo Created 8 years, 7 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/dartutils.h ('k') | runtime/bin/file_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file.cc
diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc
index aa6ada816c9a0dc268b6c070344e5e7b34c74d69..e9166e5b2b522614140405f9d2da7dc2b1718800 100644
--- a/runtime/bin/file.cc
+++ b/runtime/bin/file.cc
@@ -185,6 +185,10 @@ void FUNCTION_NAME(File_ReadList)(Dart_NativeArguments args) {
ASSERT(file != NULL);
Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1);
ASSERT(Dart_IsList(buffer_obj));
+ // Offset and length arguments are checked in Dart code to be
+ // integers and have the property that (offset + length) <=
+ // list.length. Therefore, it is safe to extract their value as
+ // 64-bit integers.
int64_t offset =
DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2));
int64_t length =
@@ -220,6 +224,10 @@ void FUNCTION_NAME(File_WriteList)(Dart_NativeArguments args) {
ASSERT(file != NULL);
Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1);
ASSERT(Dart_IsList(buffer_obj));
+ // Offset and length arguments are checked in Dart code to be
+ // integers and have the property that (offset + length) <=
+ // list.length. Therefore, it is safe to extract their value as
+ // 64-bit integers.
int64_t offset =
DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2));
int64_t length =
@@ -296,12 +304,18 @@ void FUNCTION_NAME(File_Truncate)(Dart_NativeArguments args) {
DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0));
File* file = reinterpret_cast<File*>(value);
ASSERT(file != NULL);
- int64_t length =
- DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1));
- if (file->Truncate(length)) {
- Dart_SetReturnValue(args, Dart_True());
+ int64_t length = 0;
+ if (DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 1), &length)) {
+ if (file->Truncate(length)) {
+ Dart_SetReturnValue(args, Dart_True());
+ } else {
+ Dart_Handle err = DartUtils::NewDartOSError();
+ if (Dart_IsError(err)) Dart_PropagateError(err);
+ Dart_SetReturnValue(args, err);
+ }
} else {
- Dart_Handle err = DartUtils::NewDartOSError();
+ OSError os_error(-1, "Invalid argument", OSError::kUnknown);
+ Dart_Handle err = DartUtils::NewDartOSError(&os_error);
if (Dart_IsError(err)) Dart_PropagateError(err);
Dart_SetReturnValue(args, err);
}
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698