mirror of
https://github.com/monero-project/monero.git
synced 2024-12-23 12:09:54 +00:00
portable_storage: forbid unnamed sections
This commit is contained in:
parent
00b3502749
commit
cb296b39bd
3 changed files with 3 additions and 0 deletions
|
@ -282,6 +282,7 @@ namespace epee
|
||||||
static_assert(std::is_rvalue_reference<entry_type&&>(), "unexpected copy of value");
|
static_assert(std::is_rvalue_reference<entry_type&&>(), "unexpected copy of value");
|
||||||
TRY_ENTRY();
|
TRY_ENTRY();
|
||||||
CHECK_AND_ASSERT(psection, nullptr);
|
CHECK_AND_ASSERT(psection, nullptr);
|
||||||
|
CHECK_AND_ASSERT(!pentry_name.empty(), nullptr);
|
||||||
auto ins_res = psection->m_entries.emplace(pentry_name, std::forward<entry_type>(entry));
|
auto ins_res = psection->m_entries.emplace(pentry_name, std::forward<entry_type>(entry));
|
||||||
return &ins_res.first->second;
|
return &ins_res.first->second;
|
||||||
CATCH_ENTRY("portable_storage::insert_new_entry_get_storage_entry", nullptr);
|
CATCH_ENTRY("portable_storage::insert_new_entry_get_storage_entry", nullptr);
|
||||||
|
|
|
@ -132,6 +132,7 @@ namespace epee
|
||||||
RECURSION_LIMITATION();
|
RECURSION_LIMITATION();
|
||||||
uint8_t name_len = 0;
|
uint8_t name_len = 0;
|
||||||
read(name_len);
|
read(name_len);
|
||||||
|
CHECK_AND_ASSERT_THROW_MES(name_len > 0, "Section name is missing");
|
||||||
sce_name.resize(name_len);
|
sce_name.resize(name_len);
|
||||||
read((void*)sce_name.data(), name_len);
|
read((void*)sce_name.data(), name_len);
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,6 +211,7 @@ namespace epee
|
||||||
for(const section_pair& se: sec.m_entries)
|
for(const section_pair& se: sec.m_entries)
|
||||||
{
|
{
|
||||||
CHECK_AND_ASSERT_THROW_MES(se.first.size() < std::numeric_limits<uint8_t>::max(), "storage_entry_name is too long: " << se.first.size() << ", val: " << se.first);
|
CHECK_AND_ASSERT_THROW_MES(se.first.size() < std::numeric_limits<uint8_t>::max(), "storage_entry_name is too long: " << se.first.size() << ", val: " << se.first);
|
||||||
|
CHECK_AND_ASSERT_THROW_MES(!se.first.empty(), "storage_entry_name is empty");
|
||||||
uint8_t len = static_cast<uint8_t>(se.first.size());
|
uint8_t len = static_cast<uint8_t>(se.first.size());
|
||||||
strm.write((const char*)&len, sizeof(len));
|
strm.write((const char*)&len, sizeof(len));
|
||||||
strm.write(se.first.data(), size_t(len));
|
strm.write(se.first.data(), size_t(len));
|
||||||
|
|
Loading…
Reference in a new issue