mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-26 21:03:28 +01:00
Merge pull request #7281
b9092dd
epee: also limit number of strings in portable_storage (moneromooo-monero)
This commit is contained in:
commit
e144dd5b15
@ -39,7 +39,8 @@
|
|||||||
#define EPEE_PORTABLE_STORAGE_RECURSION_LIMIT_INTERNAL 100
|
#define EPEE_PORTABLE_STORAGE_RECURSION_LIMIT_INTERNAL 100
|
||||||
#endif
|
#endif
|
||||||
#define EPEE_PORTABLE_STORAGE_OBJECT_LIMIT_INTERNAL 65536
|
#define EPEE_PORTABLE_STORAGE_OBJECT_LIMIT_INTERNAL 65536
|
||||||
#define EPEE_PORTABLE_STORAGE_OBJECT_FIELD_LIMIT_INTERNAL 262144
|
#define EPEE_PORTABLE_STORAGE_OBJECT_FIELD_LIMIT_INTERNAL 65536
|
||||||
|
#define EPEE_PORTABLE_STORAGE_STRING_LIMIT_INTERNAL 65536 // does not include field names
|
||||||
|
|
||||||
namespace epee
|
namespace epee
|
||||||
{
|
{
|
||||||
@ -107,6 +108,7 @@ namespace epee
|
|||||||
size_t m_recursion_count;
|
size_t m_recursion_count;
|
||||||
size_t m_objects;
|
size_t m_objects;
|
||||||
size_t m_fields;
|
size_t m_fields;
|
||||||
|
size_t m_strings;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline throwable_buffer_reader::throwable_buffer_reader(const void* ptr, size_t sz)
|
inline throwable_buffer_reader::throwable_buffer_reader(const void* ptr, size_t sz)
|
||||||
@ -120,6 +122,7 @@ namespace epee
|
|||||||
m_recursion_count = 0;
|
m_recursion_count = 0;
|
||||||
m_objects = 0;
|
m_objects = 0;
|
||||||
m_fields = 0;
|
m_fields = 0;
|
||||||
|
m_strings = 0;
|
||||||
}
|
}
|
||||||
inline
|
inline
|
||||||
void throwable_buffer_reader::read(void* target, size_t count)
|
void throwable_buffer_reader::read(void* target, size_t count)
|
||||||
@ -173,6 +176,11 @@ namespace epee
|
|||||||
CHECK_AND_ASSERT_THROW_MES(size <= EPEE_PORTABLE_STORAGE_OBJECT_LIMIT_INTERNAL - m_objects, "Too many objects");
|
CHECK_AND_ASSERT_THROW_MES(size <= EPEE_PORTABLE_STORAGE_OBJECT_LIMIT_INTERNAL - m_objects, "Too many objects");
|
||||||
m_objects += size;
|
m_objects += size;
|
||||||
}
|
}
|
||||||
|
else if (std::is_same<type_name, std::string>())
|
||||||
|
{
|
||||||
|
CHECK_AND_ASSERT_THROW_MES(size <= EPEE_PORTABLE_STORAGE_STRING_LIMIT_INTERNAL - m_strings, "Too many strings");
|
||||||
|
m_strings += size;
|
||||||
|
}
|
||||||
|
|
||||||
sa.reserve(size);
|
sa.reserve(size);
|
||||||
//TODO: add some optimization here later
|
//TODO: add some optimization here later
|
||||||
@ -239,6 +247,8 @@ namespace epee
|
|||||||
inline storage_entry throwable_buffer_reader::read_se<std::string>()
|
inline storage_entry throwable_buffer_reader::read_se<std::string>()
|
||||||
{
|
{
|
||||||
RECURSION_LIMITATION();
|
RECURSION_LIMITATION();
|
||||||
|
CHECK_AND_ASSERT_THROW_MES(m_strings + 1 <= EPEE_PORTABLE_STORAGE_STRING_LIMIT_INTERNAL, "Too many strings");
|
||||||
|
m_strings += 1;
|
||||||
return storage_entry(read<std::string>());
|
return storage_entry(read<std::string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user