Skip to content
Merged
Show file tree
Hide file tree
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
Binary file added cgi-bin/uploads/en.subject.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion conf/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ server {
server_name localhost;
root ./;
autoindex on;
client_max_body_size 10m;
client_max_body_size 1m;
index assets/index.html;
use_chunked_encoding true;
chunk_size 100;
Expand Down
7 changes: 7 additions & 0 deletions src/Cgi/Cgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,17 @@ int handleCgi( HttpRequest& req ){
int inputPipe[2], outputPipe[2];
pid_t pid;

size_t maxBodySize = req.getServer().getBodySize();//later add here location conf maxbody size

//clean body first
if (req.getMethod() == "POST") {
// Create a local copy of the body first
std::string body = req.getBody();
//std::cout << "body size " << body.size() << "max body size " << maxBodySize << "\n";
if(body.size() > maxBodySize ){
std::cerr << RED << "ERROR: Cgi: POST TO BIG" << END << std::endl;
return (-1);//mabe add a error page here
}
while (!body.empty() && (body[body.size()-1] == '\n' || body[body.size()-1] == '\r')) {
body.erase(body.size() -1 );
}
Expand Down