mirror of
https://github.com/matrix-construct/construct
synced 2024-10-01 05:08:59 +02:00
ircd::http: Proper exception when parse buffer is too small.
This commit is contained in:
parent
c627095f51
commit
4eeb1c093d
2 changed files with 7 additions and 2 deletions
|
@ -35,6 +35,7 @@ struct ircd::parse
|
||||||
IRCD_EXCEPTION(ircd::error, error)
|
IRCD_EXCEPTION(ircd::error, error)
|
||||||
IRCD_EXCEPTION(error, grammar_error)
|
IRCD_EXCEPTION(error, grammar_error)
|
||||||
IRCD_EXCEPTION(error, syntax_error)
|
IRCD_EXCEPTION(error, syntax_error)
|
||||||
|
IRCD_EXCEPTION(error, buffer_error)
|
||||||
|
|
||||||
using read_closure = std::function<void (char *&, char *)>;
|
using read_closure = std::function<void (char *&, char *)>;
|
||||||
using parse_closure = std::function<bool (const char *&, const char *)>;
|
using parse_closure = std::function<bool (const char *&, const char *)>;
|
||||||
|
|
|
@ -490,12 +490,16 @@ ircd::http::content::content(parse::capstan &pc,
|
||||||
pc.parsed = pc.read;
|
pc.parsed = pc.read;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(pc.parsed == base + length);
|
//assert(pc.parsed == base + length);
|
||||||
assert(pc.parsed == pc.read);
|
if(unlikely(pc.parsed < base + length))
|
||||||
|
throw parse::buffer_error("parse buffer short by %zu to hold %zu total bytes of content",
|
||||||
|
remain,
|
||||||
|
length);
|
||||||
|
|
||||||
if(pc.remaining())
|
if(pc.remaining())
|
||||||
*pc.read = '\0';
|
*pc.read = '\0';
|
||||||
|
|
||||||
|
assert(pc.parsed == pc.read);
|
||||||
return string_view { base, pc.parsed };
|
return string_view { base, pc.parsed };
|
||||||
}()}
|
}()}
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue