OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #include "snapshot/minidump/minidump_string_list_reader.h" |
| 16 |
| 17 #include "base/logging.h" |
| 18 #include "minidump/minidump_extensions.h" |
| 19 #include "snapshot/minidump/minidump_string_reader.h" |
| 20 |
| 21 namespace crashpad { |
| 22 namespace internal { |
| 23 |
| 24 bool ReadMinidumpStringList(FileReaderInterface* file_reader, |
| 25 const MINIDUMP_LOCATION_DESCRIPTOR& location, |
| 26 std::vector<std::string>* list) { |
| 27 if (location.Rva == 0) { |
| 28 list->clear(); |
| 29 return true; |
| 30 } |
| 31 |
| 32 if (location.DataSize < sizeof(MinidumpRVAList)) { |
| 33 LOG(ERROR) << "string_list size mismatch"; |
| 34 return false; |
| 35 } |
| 36 |
| 37 if (!file_reader->SeekSet(location.Rva)) { |
| 38 return false; |
| 39 } |
| 40 |
| 41 uint32_t entry_count; |
| 42 if (!file_reader->ReadExactly(&entry_count, sizeof(entry_count))) { |
| 43 return false; |
| 44 } |
| 45 |
| 46 if (location.DataSize != |
| 47 sizeof(MinidumpRVAList) + entry_count * sizeof(RVA)) { |
| 48 LOG(ERROR) << "string_list size mismatch"; |
| 49 return false; |
| 50 } |
| 51 |
| 52 std::vector<RVA> rvas(entry_count); |
| 53 if (!file_reader->ReadExactly(&rvas[0], entry_count * sizeof(rvas[0]))) { |
| 54 return false; |
| 55 } |
| 56 |
| 57 std::vector<std::string> local_list; |
| 58 for (RVA rva : rvas) { |
| 59 std::string element; |
| 60 if (!ReadMinidumpUTF8String(file_reader, rva, &element)) { |
| 61 return false; |
| 62 } |
| 63 |
| 64 local_list.push_back(element); |
| 65 } |
| 66 |
| 67 list->swap(local_list); |
| 68 return true; |
| 69 } |
| 70 |
| 71 } // namespace internal |
| 72 } // namespace crashpad |
OLD | NEW |