OLD | NEW |
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 #include <stddef.h> | 6 #include <stddef.h> |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/memory_mapped_file.h" | 10 #include "base/files/memory_mapped_file.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 bool Reader::ReadNameTable() { | 159 bool Reader::ReadNameTable() { |
160 for (size_t i = 0; i < header_->name_count; ++i) { | 160 for (size_t i = 0; i < header_->name_count; ++i) { |
161 const NameTableEntry* entry; | 161 const NameTableEntry* entry; |
162 if (!CutObject<NameTableEntry>(&entry)) | 162 if (!CutObject<NameTableEntry>(&entry)) |
163 return false; | 163 return false; |
164 size_t offset = entry->string_table_offset; | 164 size_t offset = entry->string_table_offset; |
165 if (offset >= string_table_.size()) { | 165 if (offset >= string_table_.size()) { |
166 LOG(ERROR) << "Invalid string table offset: " << offset; | 166 LOG(ERROR) << "Invalid string table offset: " << offset; |
167 return false; | 167 return false; |
168 } | 168 } |
169 name_map_.Add(entry->type, std::string(string_table_.data() + offset)); | 169 name_map_.Add(entry->type, string_table_.data() + offset); |
170 } | 170 } |
171 return true; | 171 return true; |
172 } | 172 } |
173 | 173 |
174 bool Reader::RemoveUnknownMessages() { | 174 bool Reader::RemoveUnknownMessages() { |
175 MessageVector::iterator it = messages_->begin(); | 175 MessageVector::iterator it = messages_->begin(); |
176 while (it != messages_->end()) { | 176 while (it != messages_->end()) { |
177 uint32_t type = (*it)->type(); | 177 uint32_t type = (*it)->type(); |
178 if (!name_map_.TypeExists(type)) { | 178 if (!name_map_.TypeExists(type)) { |
179 LOG(ERROR) << "Missing name table entry for type " << type; | 179 LOG(ERROR) << "Missing name table entry for type " << type; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 226 } |
227 | 227 |
228 } // namespace | 228 } // namespace |
229 | 229 |
230 bool MessageFile::Read(const base::FilePath& path, MessageVector* messages) { | 230 bool MessageFile::Read(const base::FilePath& path, MessageVector* messages) { |
231 Reader reader(path); | 231 Reader reader(path); |
232 return reader.Read(messages); | 232 return reader.Read(messages); |
233 } | 233 } |
234 | 234 |
235 } // namespace ipc_fuzzer | 235 } // namespace ipc_fuzzer |
OLD | NEW |