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

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
« no previous file with comments | « runtime/vm/dart_api_message.cc ('k') | runtime/vm/message.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/isolate.cc
===================================================================
--- runtime/vm/isolate.cc (revision 11409)
+++ runtime/vm/isolate.cc (working copy)
@@ -80,26 +80,27 @@
}
-static RawInstance* DeserializeMessage(void* data) {
- // Create a snapshot object using the buffer.
- const Snapshot* snapshot = Snapshot::SetupFromBuffer(data);
- ASSERT(snapshot->IsMessageSnapshot());
-
- // Read object back from the snapshot.
- SnapshotReader reader(snapshot, Isolate::Current());
- Instance& instance = Instance::Handle();
- instance ^= reader.ReadObject();
- return instance.raw();
-}
-
-
bool IsolateMessageHandler::HandleMessage(Message* message) {
StartIsolateScope start_scope(isolate_);
Zone zone(isolate_);
HandleScope handle_scope(isolate_);
- const Instance& msg =
- Instance::Handle(DeserializeMessage(message->data()));
+ // Parse the message.
+ SnapshotReader reader(message->data(), message->len(),
+ Snapshot::kMessage, Isolate::Current());
+ const Object& msg_obj = Object::Handle(reader.ReadObject());
+ if (!msg_obj.IsNull() && !msg_obj.IsInstance()) {
+ // TODO(turnidge): We need to decide what an isolate does with
+ // malformed messages. If they (eventually) come from a remote
+ // machine, then it might make sense to drop the message entirely.
+ // In the case that the message originated locally, which is
+ // always true for now, then this should never occur.
+ UNREACHABLE();
+ }
+
+ Instance& msg = Instance::Handle();
+ msg ^= msg_obj.raw(); // Can't use Instance::Cast because may be null.
+
if (message->IsOOB()) {
// For now the only OOB messages are Mirrors messages.
HandleMirrorsMessage(isolate_, message->reply_port(), msg);
« no previous file with comments | « runtime/vm/dart_api_message.cc ('k') | runtime/vm/message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698