aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/storages
diff options
context:
space:
mode:
authormoneromooo <moneromoo@nowhere.nowhere.nowhere>2020-12-31 16:27:27 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-12-31 22:35:17 +0000
commit8e2caf3fb4101483af8ffbe1e5996bcc372b8c53 (patch)
tree90bf320eb814a3578f5cccbf871dcb56845242f3 /contrib/epee/include/storages
parentMerge pull request #7221 (diff)
downloadmonero-8e2caf3fb4101483af8ffbe1e5996bcc372b8c53.tar.xz
portable_storage: check object limit where appropriate
also fix pedantic off by one in check
Diffstat (limited to 'contrib/epee/include/storages')
-rw-r--r--contrib/epee/include/storages/portable_storage_from_bin.h7
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--)
{