mirror of
https://github.com/matrix-construct/construct
synced 2024-06-12 23:18:55 +02:00
ircd::conf: Enforce a max length on name strings.
This commit is contained in:
parent
1711df33a9
commit
71d772a80c
|
@ -62,6 +62,8 @@ namespace ircd::conf
|
|||
template<>
|
||||
struct ircd::conf::item<void>
|
||||
{
|
||||
static const size_t NAME_MAX_LEN;
|
||||
|
||||
json::strung feature_;
|
||||
json::object feature;
|
||||
string_view name;
|
||||
|
|
15
ircd/conf.cc
15
ircd/conf.cc
|
@ -135,6 +135,12 @@ ircd::conf::exists(const string_view &key)
|
|||
// item
|
||||
//
|
||||
|
||||
decltype(ircd::conf::item<void>::NAME_MAX_LEN)
|
||||
ircd::conf::item<void>::NAME_MAX_LEN
|
||||
{
|
||||
127
|
||||
};
|
||||
|
||||
/// Conf item abstract constructor.
|
||||
ircd::conf::item<void>::item(const json::members &opts,
|
||||
conf::set_cb set_cb)
|
||||
|
@ -155,6 +161,15 @@ ircd::conf::item<void>::item(const json::members &opts,
|
|||
std::move(set_cb)
|
||||
}
|
||||
{
|
||||
if(size(name) > NAME_MAX_LEN)
|
||||
throw error
|
||||
{
|
||||
"Conf item '%s' name length:%zu exceeds max:%zu",
|
||||
name,
|
||||
size(name),
|
||||
NAME_MAX_LEN
|
||||
};
|
||||
|
||||
if(!items.emplace(name, this).second)
|
||||
throw error
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue