aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/storages/levin_abstract_invoke2.h
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2021-01-06 13:19:58 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2021-01-07 20:24:29 +0000
commit372754a66e6492590f9fdf2af519f03eb38d5e0f (patch)
tree667af79016b01a67fd25d1834c29b935fe9a9dd8 /contrib/epee/include/storages/levin_abstract_invoke2.h
parentMerge pull request #7281 (diff)
downloadmonero-372754a66e6492590f9fdf2af519f03eb38d5e0f.tar.xz
storages: overridable limits for loading portable_storage from binary
Diffstat (limited to 'contrib/epee/include/storages/levin_abstract_invoke2.h')
-rw-r--r--contrib/epee/include/storages/levin_abstract_invoke2.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/contrib/epee/include/storages/levin_abstract_invoke2.h b/contrib/epee/include/storages/levin_abstract_invoke2.h
index 95f0bb410..802e16c1b 100644
--- a/contrib/epee/include/storages/levin_abstract_invoke2.h
+++ b/contrib/epee/include/storages/levin_abstract_invoke2.h
@@ -52,6 +52,11 @@ namespace
snprintf(buf, sizeof(buf), "command-%u", command);
return on_levin_traffic(context, initiator, sent, error, bytes, buf);
}
+ static const constexpr epee::serialization::portable_storage::limits_t default_levin_limits = {
+ 8192, // objects
+ 16384, // fields
+ 16384, // strings
+ };
}
namespace epee
@@ -77,7 +82,7 @@ namespace epee
return false;
}
serialization::portable_storage stg_ret;
- if(!stg_ret.load_from_binary(buff_to_recv))
+ if(!stg_ret.load_from_binary(buff_to_recv, &default_levin_limits))
{
LOG_ERROR("Failed to load_from_binary on command " << command);
return false;
@@ -124,7 +129,7 @@ namespace epee
return false;
}
typename serialization::portable_storage stg_ret;
- if(!stg_ret.load_from_binary(buff_to_recv))
+ if(!stg_ret.load_from_binary(buff_to_recv, &default_levin_limits))
{
on_levin_traffic(context, true, false, true, buff_to_recv.size(), command);
LOG_ERROR("Failed to load_from_binary on command " << command);
@@ -155,7 +160,7 @@ namespace epee
return false;
}
serialization::portable_storage stg_ret;
- if(!stg_ret.load_from_binary(buff))
+ if(!stg_ret.load_from_binary(buff, &default_levin_limits))
{
on_levin_traffic(context, true, false, true, buff.size(), command);
LOG_ERROR("Failed to load_from_binary on command " << command);
@@ -205,7 +210,7 @@ namespace epee
int buff_to_t_adapter(int command, const epee::span<const uint8_t> in_buff, byte_slice& buff_out, callback_t cb, t_context& context )
{
serialization::portable_storage strg;
- if(!strg.load_from_binary(in_buff))
+ if(!strg.load_from_binary(in_buff, &default_levin_limits))
{
on_levin_traffic(context, false, false, true, in_buff.size(), command);
LOG_ERROR("Failed to load_from_binary in command " << command);
@@ -239,7 +244,7 @@ namespace epee
int buff_to_t_adapter(t_owner* powner, int command, const epee::span<const uint8_t> in_buff, callback_t cb, t_context& context)
{
serialization::portable_storage strg;
- if(!strg.load_from_binary(in_buff))
+ if(!strg.load_from_binary(in_buff, &default_levin_limits))
{
on_levin_traffic(context, false, false, true, in_buff.size(), command);
LOG_ERROR("Failed to load_from_binary in notify " << command);