0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-28 14:58:20 +02:00

ircd::http: Proper exception when parse buffer is too small.

This commit is contained in:
Jason Volk 2017-09-08 01:55:18 -07:00
parent c627095f51
commit 4eeb1c093d
2 changed files with 7 additions and 2 deletions

View file

@ -35,6 +35,7 @@ struct ircd::parse
IRCD_EXCEPTION(ircd::error, error)
IRCD_EXCEPTION(error, grammar_error)
IRCD_EXCEPTION(error, syntax_error)
IRCD_EXCEPTION(error, buffer_error)
using read_closure = std::function<void (char *&, char *)>;
using parse_closure = std::function<bool (const char *&, const char *)>;

View file

@ -490,12 +490,16 @@ ircd::http::content::content(parse::capstan &pc,
pc.parsed = pc.read;
}
assert(pc.parsed == base + length);
assert(pc.parsed == pc.read);
//assert(pc.parsed == base + length);
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())
*pc.read = '\0';
assert(pc.parsed == pc.read);
return string_view { base, pc.parsed };
}()}
{