Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make multipart robust against ill-formed body, prevents SIGSEGV #385

Merged
merged 3 commits into from
Apr 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion include/crow/multipart.h
Original file line number Diff line number Diff line change
Expand Up @@ -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] == '\"')
Expand All @@ -173,6 +173,11 @@ 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.
Expand Down