diff options
author | Alexander Blair <snipa@jagtech.io> | 2021-01-01 22:42:43 -0800 |
---|---|---|
committer | Alexander Blair <snipa@jagtech.io> | 2021-01-01 22:42:43 -0800 |
commit | 024783f73ab95ad352359d89552d938642e5d9cc (patch) | |
tree | f4a5338bb8e8dd47a4a4f5ef127cce9cd260f67c /contrib | |
parent | Merge pull request #7239 (diff) | |
parent | portable_storage: check object limit where appropriate (diff) | |
download | monero-024783f73ab95ad352359d89552d938642e5d9cc.tar.xz |
Merge pull request #7244
531069859 portable_storage: check object limit where appropriate (moneromooo)
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/epee/include/storages/portable_storage_from_bin.h | 7 |
1 files changed, 6 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..1d6a09c41 100644 --- a/contrib/epee/include/storages/portable_storage_from_bin.h +++ b/contrib/epee/include/storages/portable_storage_from_bin.h @@ -163,6 +163,11 @@ namespace epee array_entry_t<type_name> sa; size_t size = read_varint(); CHECK_AND_ASSERT_THROW_MES(size <= m_count / ps_min_bytes<type_name>::strict, "Size sanity check failed"); + if (std::is_same<type_name, section>()) + { + CHECK_AND_ASSERT_THROW_MES(size <= EPEE_PORTABLE_STORAGE_OBJECT_LIMIT_INTERNAL - m_objects, "Too many objects"); + m_objects += size; + } sa.reserve(size); //TODO: add some optimization here later @@ -288,7 +293,7 @@ namespace epee RECURSION_LIMITATION(); sec.m_entries.clear(); size_t count = read_varint(); - CHECK_AND_ASSERT_THROW_MES(count < EPEE_PORTABLE_STORAGE_OBJECT_LIMIT_INTERNAL - m_objects, "Too many objects"); + CHECK_AND_ASSERT_THROW_MES(count <= EPEE_PORTABLE_STORAGE_OBJECT_LIMIT_INTERNAL - m_objects, "Too many objects"); m_objects += count; while(count--) { |