mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
make multipart robust against ill-formed body, prevents SIGSEGV
This commit is contained in:
parent
1002ded116
commit
7c285db88c
@ -152,7 +152,7 @@ namespace crow
|
||||
{
|
||||
constexpr char boundary_text[] = "boundary=";
|
||||
size_t found = header.find(boundary_text);
|
||||
if (found)
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
std::string to_return(header.substr(found + strlen(boundary_text)));
|
||||
if (to_return[0] == '\"')
|
||||
@ -173,6 +173,10 @@ namespace crow
|
||||
while (body != (crlf))
|
||||
{
|
||||
size_t found = body.find(delimiter);
|
||||
if (found == std::string::npos) {
|
||||
// did not find delimiter; probably an ill-formed body; ignore the rest
|
||||
break;
|
||||
}
|
||||
std::string section = body.substr(0, found);
|
||||
|
||||
// +2 is the CRLF.
|
||||
|
Loading…
Reference in New Issue
Block a user