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
10 changes: 8 additions & 2 deletions src/http/cgi/execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,14 @@ HttpResponse CgiHandler::execute(const HttpRequest& request, const LocationConfi

int stdinPipe[2];
int stdoutPipe[2];
if (pipe(stdinPipe) == -1 || pipe(stdoutPipe) == -1)
if (pipe(stdinPipe) == -1)
return buildHttpError(500, "Internal Server Error");
if (pipe(stdoutPipe) == -1)
{
close(stdinPipe[0]);
close(stdinPipe[1]);
return buildHttpError(500, "Internal Server Error");
}

pid_t childPid = fork();
if (childPid == -1)
Expand All @@ -118,7 +124,7 @@ HttpResponse CgiHandler::execute(const HttpRequest& request, const LocationConfi
}

if (childPid == 0)
runChildProcess(interpreter, scriptPath, argv, envPointers.data(), stdinPipe, stdoutPipe);
runChildProcess(interpreter, scriptPath, argv, &envPointers[0], stdinPipe, stdoutPipe);

close(stdinPipe[0]);
close(stdoutPipe[1]);
Expand Down
7 changes: 1 addition & 6 deletions src/http/handlers/GetHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ static HttpResponse buildAutoindex(const std::string& directoryPath, const std::
{
DIR* directory = opendir(directoryPath.c_str());
if (!directory)
{
HttpResponse response;
response.status_code = 403;
response.status_msg = "Forbidden";
return response;
}
return buildHttpError(403, "Forbidden");

std::string listingHtml = "<html><body><h1>Index of " + requestUri + "</h1><ul>";

Expand Down
Loading