Skip to content

Commit

Permalink
[httpd] Fix scan-build make warning from commit 3a03c74
Browse files Browse the repository at this point in the history
Potential buffer overflow
  • Loading branch information
ejurgensen committed Mar 15, 2021
1 parent 1c62469 commit 19635e6
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/httpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ serve_file(struct evhttp_request *req, const char *uri)
return;
}


if (!realpath(path, deref))
{
DPRINTF(E_LOG, L_HTTPD, "Could not dereference %s: %s\n", path, strerror(errno));
Expand Down Expand Up @@ -420,7 +419,7 @@ serve_file(struct evhttp_request *req, const char *uri)
if (S_ISDIR(sb.st_mode))
{
slashed = (path[strlen(path) - 1] == '/');
strncat(path, ((slashed) ? "index.html" : "/index.html"), sizeof(path) - strlen(path));
strncat(path, ((slashed) ? "index.html" : "/index.html"), sizeof(path) - strlen(path) - 1);

if (!realpath(path, deref))
{
Expand Down

0 comments on commit 19635e6

Please sign in to comment.