mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 08:12:37 +01:00
ircd:Ⓜ️:dbs: Add explicit truncations to limit specific key elements.
This commit is contained in:
parent
dcd50f3427
commit
1bdc87c55e
5 changed files with 12 additions and 8 deletions
|
@ -247,23 +247,27 @@ ircd::m::dbs::event_state_key(const mutable_buffer &out_,
|
|||
return {};
|
||||
|
||||
mutable_buffer out{out_};
|
||||
consume(out, copy(out, state_key));
|
||||
consume(out, copy(out, trunc(state_key, event::STATE_KEY_MAX_SIZE)));
|
||||
|
||||
if(!type)
|
||||
return {data(out_), data(out)};
|
||||
|
||||
consume(out, copy(out, "\0"_sv));
|
||||
consume(out, copy(out, type));
|
||||
consume(out, copy(out, trunc(type, event::TYPE_MAX_SIZE)));
|
||||
|
||||
if(!room_id)
|
||||
return {data(out_), data(out)};
|
||||
|
||||
assert(m::valid(m::id::ROOM, room_id));
|
||||
consume(out, copy(out, "\0"_sv));
|
||||
consume(out, copy(out, room_id));
|
||||
|
||||
if(depth < 0)
|
||||
return {data(out_), data(out)};
|
||||
|
||||
consume(out, copy(out, "\0"_sv));
|
||||
consume(out, copy(out, byte_view<string_view>(depth)));
|
||||
|
||||
if(!event_idx)
|
||||
return {data(out_), data(out)};
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ ircd::m::dbs::event_type_key(const mutable_buffer &out_,
|
|||
assert(size(out_) >= EVENT_TYPE_KEY_MAX_SIZE);
|
||||
|
||||
mutable_buffer out{out_};
|
||||
consume(out, copy(out, type));
|
||||
consume(out, copy(out, trunc(type, event::TYPE_MAX_SIZE)));
|
||||
consume(out, copy(out, "\0"_sv));
|
||||
consume(out, copy(out, byte_view<string_view>(event_idx)));
|
||||
return { data(out_), data(out) };
|
||||
|
|
|
@ -202,13 +202,13 @@ ircd::m::dbs::room_state_key(const mutable_buffer &out_,
|
|||
if(likely(defined(type)))
|
||||
{
|
||||
consume(out, copy(out, "\0"_sv));
|
||||
consume(out, copy(out, type));
|
||||
consume(out, copy(out, trunc(type, event::TYPE_MAX_SIZE)));
|
||||
}
|
||||
|
||||
if(defined(state_key))
|
||||
{
|
||||
consume(out, copy(out, "\0"_sv));
|
||||
consume(out, copy(out, state_key));
|
||||
consume(out, copy(out, trunc(state_key, event::STATE_KEY_MAX_SIZE)));
|
||||
}
|
||||
|
||||
return { data(out_), data(out) };
|
||||
|
|
|
@ -326,9 +326,9 @@ ircd::m::dbs::room_state_space_key(const mutable_buffer &out_,
|
|||
mutable_buffer out{out_};
|
||||
consume(out, copy(out, room_id));
|
||||
consume(out, copy(out, "\0"_sv));
|
||||
consume(out, copy(out, type));
|
||||
consume(out, copy(out, trunc(type, event::TYPE_MAX_SIZE)));
|
||||
consume(out, copy(out, "\0"_sv));
|
||||
consume(out, copy(out, state_key));
|
||||
consume(out, copy(out, trunc(state_key, event::STATE_KEY_MAX_SIZE)));
|
||||
consume(out, copy(out, "\0"_sv));
|
||||
consume(out, copy(out, byte_view<string_view>(depth)));
|
||||
consume(out, copy(out, byte_view<string_view>(event_idx)));
|
||||
|
|
|
@ -306,7 +306,7 @@ ircd::m::dbs::room_type_key(const mutable_buffer &out_,
|
|||
return { data(out_), data(out) };
|
||||
|
||||
consume(out, copy(out, "\0"_sv));
|
||||
consume(out, copy(out, type));
|
||||
consume(out, copy(out, trunc(type, event::TYPE_MAX_SIZE)));
|
||||
consume(out, copy(out, "\0"_sv));
|
||||
consume(out, copy(out, byte_view<string_view>(depth)));
|
||||
consume(out, copy(out, byte_view<string_view>(event_idx)));
|
||||
|
|
Loading…
Reference in a new issue