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

Side by Side Diff: tools/ipc_fuzzer/message_lib/message_file_reader.cc

Issue 1308613006: ipc: Update Message::FindNext to parse brokered attachments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « ipc/ipc_message.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits.h> 5 #include <limits.h>
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/memory_mapped_file.h" 8 #include "base/files/memory_mapped_file.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 const char* data = reinterpret_cast<const char*>(mapped_file_.data()); 102 const char* data = reinterpret_cast<const char*>(mapped_file_.data());
103 file_data_.set(data, mapped_file_.length()); 103 file_data_.set(data, mapped_file_.length());
104 return true; 104 return true;
105 } 105 }
106 106
107 bool Reader::ReadMessages() { 107 bool Reader::ReadMessages() {
108 for (size_t i = 0; i < header_->message_count; ++i) { 108 for (size_t i = 0; i < header_->message_count; ++i) {
109 const char* begin = file_data_.begin(); 109 const char* begin = file_data_.begin();
110 const char* end = file_data_.end(); 110 const char* end = file_data_.end();
111 const char* message_tail = IPC::Message::FindNext(begin, end); 111 Message::NextMessageInfo info;
112 if (!message_tail) { 112 IPC::Message::FindNext(begin, end, &info);
113 if (!info.message_found) {
113 LOG(ERROR) << "Failed to parse message."; 114 LOG(ERROR) << "Failed to parse message.";
114 return false; 115 return false;
115 } 116 }
116 117
117 size_t msglen = message_tail - begin; 118 CHECK_EQ(info.message_end, info.pickle_end);
119 size_t msglen = info.message_end - begin;
118 if (msglen > INT_MAX) { 120 if (msglen > INT_MAX) {
119 LOG(ERROR) << "Message too large."; 121 LOG(ERROR) << "Message too large.";
120 return false; 122 return false;
121 } 123 }
122 124
123 // Copy is necessary to fix message type later. 125 // Copy is necessary to fix message type later.
124 IPC::Message const_message(begin, msglen); 126 IPC::Message const_message(begin, msglen);
125 IPC::Message* message = new IPC::Message(const_message); 127 IPC::Message* message = new IPC::Message(const_message);
126 messages_->push_back(message); 128 messages_->push_back(message);
127 file_data_.remove_prefix(msglen); 129 file_data_.remove_prefix(msglen);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 223 }
222 224
223 } // namespace 225 } // namespace
224 226
225 bool MessageFile::Read(const base::FilePath& path, MessageVector* messages) { 227 bool MessageFile::Read(const base::FilePath& path, MessageVector* messages) {
226 Reader reader(path); 228 Reader reader(path);
227 return reader.Read(messages); 229 return reader.Read(messages);
228 } 230 }
229 231
230 } // namespace ipc_fuzzer 232 } // namespace ipc_fuzzer
OLDNEW
« no previous file with comments | « ipc/ipc_message.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698