| OLD | NEW |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 if (!file_reader->SeekSet(location.Rva)) { | 41 if (!file_reader->SeekSet(location.Rva)) { |
| 42 return false; | 42 return false; |
| 43 } | 43 } |
| 44 | 44 |
| 45 uint32_t entry_count; | 45 uint32_t entry_count; |
| 46 if (!file_reader->ReadExactly(&entry_count, sizeof(entry_count))) { | 46 if (!file_reader->ReadExactly(&entry_count, sizeof(entry_count))) { |
| 47 return false; | 47 return false; |
| 48 } | 48 } |
| 49 | 49 |
| 50 if (location.DataSize != | 50 if (location.DataSize != |
| 51 entry_count * sizeof(MinidumpSimpleStringDictionaryEntry)) { | 51 sizeof(MinidumpSimpleStringDictionary) + |
| 52 entry_count * sizeof(MinidumpSimpleStringDictionaryEntry)) { |
| 52 LOG(ERROR) << "simple_string_dictionary size mismatch"; | 53 LOG(ERROR) << "simple_string_dictionary size mismatch"; |
| 53 return false; | 54 return false; |
| 54 } | 55 } |
| 55 | 56 |
| 56 std::vector<MinidumpSimpleStringDictionaryEntry> entries(entry_count); | 57 std::vector<MinidumpSimpleStringDictionaryEntry> entries(entry_count); |
| 57 if (!file_reader->ReadExactly(&entries[0], | 58 if (!file_reader->ReadExactly(&entries[0], |
| 58 entry_count * sizeof(entries[0]))) { | 59 entry_count * sizeof(entries[0]))) { |
| 59 return false; | 60 return false; |
| 60 } | 61 } |
| 61 | 62 |
| 62 std::map<std::string, std::string> local_dictionary; | 63 std::map<std::string, std::string> local_dictionary; |
| 63 for (const MinidumpSimpleStringDictionaryEntry& entry : entries) { | 64 for (const MinidumpSimpleStringDictionaryEntry& entry : entries) { |
| 64 std::string key; | 65 std::string key; |
| 65 if (!ReadMinidumpUTF8String(file_reader, entry.key, &key)) { | 66 if (!ReadMinidumpUTF8String(file_reader, entry.key, &key)) { |
| 66 // Not a hard error, keep trying. | 67 return false; |
| 67 continue; | |
| 68 } | 68 } |
| 69 | 69 |
| 70 std::string value; | 70 std::string value; |
| 71 if (!ReadMinidumpUTF8String(file_reader, entry.value, &value)) { | 71 if (!ReadMinidumpUTF8String(file_reader, entry.value, &value)) { |
| 72 // Not a hard error, keep trying. | 72 return false; |
| 73 continue; | |
| 74 } | 73 } |
| 75 | 74 |
| 76 if (local_dictionary.find(key) != local_dictionary.end()) { | 75 if (local_dictionary.find(key) != local_dictionary.end()) { |
| 77 LOG(WARNING) << "duplicate key " << key << ", discarding value " << value; | 76 LOG(WARNING) << "duplicate key " << key << ", discarding value " << value; |
| 78 continue; | 77 return false; |
| 79 } | 78 } |
| 80 | 79 |
| 81 local_dictionary.insert(std::make_pair(key, value)); | 80 local_dictionary.insert(std::make_pair(key, value)); |
| 82 } | 81 } |
| 83 | 82 |
| 84 dictionary->swap(local_dictionary); | 83 dictionary->swap(local_dictionary); |
| 85 return true; | 84 return true; |
| 86 } | 85 } |
| 87 | 86 |
| 88 } // namespace internal | 87 } // namespace internal |
| 89 } // namespace crashpad | 88 } // namespace crashpad |
| OLD | NEW |