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

Unified Diff: runtime/vm/isolate.cc

Issue 10829444: Avoid trusting the length encoded in the Snapshot if there is an (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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
Index: runtime/vm/isolate.cc
===================================================================
--- runtime/vm/isolate.cc (revision 10993)
+++ runtime/vm/isolate.cc (working copy)
@@ -80,26 +80,35 @@
}
-static RawInstance* DeserializeMessage(void* data) {
- // Create a snapshot object using the buffer.
- const Snapshot* snapshot = Snapshot::SetupFromBuffer(data);
- ASSERT(snapshot->IsMessageSnapshot());
+bool IsolateMessageHandler::HandleMessage(Message* message) {
+ StartIsolateScope start_scope(isolate_);
+ Zone zone(isolate_);
+ HandleScope handle_scope(isolate_);
+ const Snapshot* snapshot = Snapshot::SetupFromBuffer(message->data(),
+ message->len());
+ if (snapshot == NULL || !snapshot->IsMessageSnapshot()) {
+ if (message->IsLocal()) {
+ FATAL("IsolateMessageHandler saw malformed message. Exiting.");
siva 2012/08/22 23:30:39 Do these really need to be fatal errors? We could
turnidge 2012/08/23 18:37:57 I believe it should be fatal, yes. Made this UNRE
+ }
+ delete message;
+ return true;
+ }
+
// Read object back from the snapshot.
SnapshotReader reader(snapshot, Isolate::Current());
- Instance& instance = Instance::Handle();
- instance ^= reader.ReadObject();
- return instance.raw();
-}
+ const Object& msg_obj = Object::Handle(reader.ReadObject());
+ if (!msg_obj.IsNull() && !msg_obj.IsInstance()) {
+ if (message->IsLocal()) {
+ FATAL("IsolateMessageHandler saw malformed message. Exiting.");
siva 2012/08/22 23:30:39 Ditto comment.
turnidge 2012/08/23 18:37:57 This goes away in new revision.
+ }
+ delete message;
+ return true;
+ }
+ Instance& msg = Instance::Handle();
+ msg ^= msg_obj.raw(); // Can't use Instance::Cast because may be null.
-bool IsolateMessageHandler::HandleMessage(Message* message) {
- StartIsolateScope start_scope(isolate_);
- Zone zone(isolate_);
- HandleScope handle_scope(isolate_);
-
- const Instance& msg =
- Instance::Handle(DeserializeMessage(message->data()));
if (message->IsOOB()) {
// For now the only OOB messages are Mirrors messages.
HandleMirrorsMessage(isolate_, message->reply_port(), msg);

Powered by Google App Engine
This is Rietveld 408576698