diff options
| author | Alexander Blair <snipa@jagtech.io> | 2021-01-01 22:32:53 -0800 |
|---|---|---|
| committer | Alexander Blair <snipa@jagtech.io> | 2021-01-01 22:32:53 -0800 |
| commit | 175aa2497a44ca9e47e0d99d8f9b3ce1d3f81648 (patch) | |
| tree | f484ea864cb0a60feeb1b9b9671b743b33ced811 | |
| parent | 2d60232355774113166956bb34819606eb977907 (diff) | |
| parent | 8e2caf3fb4101483af8ffbe1e5996bcc372b8c53 (diff) | |
| download | monzero-core-175aa2497a44ca9e47e0d99d8f9b3ce1d3f81648.tar.gz monzero-core-175aa2497a44ca9e47e0d99d8f9b3ce1d3f81648.tar.xz monzero-core-175aa2497a44ca9e47e0d99d8f9b3ce1d3f81648.zip | |
Merge pull request #7243
8e2caf3fb portable_storage: check object limit where appropriate (moneromooo)
| -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 04708700a..631ad307b 100644 --- a/contrib/epee/include/storages/portable_storage_from_bin.h +++ b/contrib/epee/include/storages/portable_storage_from_bin.h @@ -164,6 +164,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 @@ -289,7 +294,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--) { |
