diff options
author | Lee Clagett <code@leeclagett.com> | 2020-12-31 20:40:50 -0500 |
---|---|---|
committer | Lee Clagett <code@leeclagett.com> | 2020-12-17 01:04:00 +0000 |
commit | f0b867b13dc222c208b0f6fb03e810bf774d4b32 (patch) | |
tree | af0a95a855bba5e92925d1902d8108ddc590e3b3 /contrib/epee/include | |
parent | Merge pull request #7228 from vtnerd/fix/p2p_memory_usage_017 (diff) | |
download | monero-f0b867b13dc222c208b0f6fb03e810bf774d4b32.tar.xz |
Restrict duplicate keys in epee binary format
Diffstat (limited to 'contrib/epee/include')
-rw-r--r-- | contrib/epee/include/storages/portable_storage_from_bin.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/contrib/epee/include/storages/portable_storage_from_bin.h b/contrib/epee/include/storages/portable_storage_from_bin.h index eb0eed235..b307c417b 100644 --- a/contrib/epee/include/storages/portable_storage_from_bin.h +++ b/contrib/epee/include/storages/portable_storage_from_bin.h @@ -295,7 +295,9 @@ namespace epee //read section name string std::string sec_name; read_sec_name(sec_name); - sec.m_entries.emplace(std::move(sec_name), load_storage_entry()); + const auto insert_loc = sec.m_entries.lower_bound(sec_name); + CHECK_AND_ASSERT_THROW_MES(insert_loc == sec.m_entries.end() || insert_loc->first != sec_name, "duplicate key: " << sec_name); + sec.m_entries.emplace_hint(insert_loc, std::move(sec_name), load_storage_entry()); } } inline |