Send error 400 when content-size is 0 or omitted for POST

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5246 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2006-09-14 11:42:03 +00:00
parent 0f66106f8c
commit 3b809f52ad

View File

@ -220,6 +220,12 @@ class HttpSocket : public InspSocket
postsize = atoi(header_item.c_str()); postsize = atoi(header_item.c_str());
} }
} }
if (!postsize)
{
SendHeaders(0, 400, "");
}
else
{
Instance->Log(DEBUG,"%d bytes to read for POST",postsize); Instance->Log(DEBUG,"%d bytes to read for POST",postsize);
std::string::size_type x = headers.str().find("\r\n\r\n"); std::string::size_type x = headers.str().find("\r\n\r\n");
postdata = headers.str().substr(x+5, headers.str().length()); postdata = headers.str().substr(x+5, headers.str().length());
@ -227,16 +233,15 @@ class HttpSocket : public InspSocket
if (postdata.length() >= postsize) if (postdata.length() >= postsize)
ServeData(); ServeData();
} }
}
else if (InternalState == HTTP_SERVE_RECV_POSTDATA) else if (InternalState == HTTP_SERVE_RECV_POSTDATA)
{ {
/* Add postdata, once we have it all, send the event */ /* Add postdata, once we have it all, send the event */
amount += strlen(data); amount += strlen(data);
postdata.append(data); postdata.append(data);
if (amount >= postsize) if (amount >= postsize)
{
ServeData(); ServeData();
} }
}
else else
{ {
ServeData(); ServeData();