Skip to content

Commit

Permalink
fix(HTTPRequest): small overflow on mac in setRequestTarget if the ta…
Browse files Browse the repository at this point in the history
…rget is an empty string
  • Loading branch information
552020 committed May 17, 2024
1 parent c494d30 commit 60cd38d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/HTTPRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void HTTPRequest::setMethod(std::string method)

void HTTPRequest::setRequestTarget(std::string requestTarget)
{
if (requestTarget != "/" && requestTarget[requestTarget.size() - 1] == '/')
if (!requestTarget.empty() && requestTarget != "/" && requestTarget.back() == '/')
requestTarget = requestTarget.substr(0, requestTarget.size() - 1);
_requestTarget = requestTarget;
}
Expand Down
7 changes: 7 additions & 0 deletions webserv_default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@ server {
allow_methods GET POST DELETE;
autoindex off;
root var/;
}

server {
listen 8080;
server_name www.php_site;
allow_methods GET POST DELETE;
root var/;
}

0 comments on commit 60cd38d

Please sign in to comment.