From 19635e61ec5e9896dacba98071fe4dbb3580f1e5 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Mon, 15 Mar 2021 21:59:40 +0100 Subject: [PATCH] [httpd] Fix scan-build make warning from commit 3a03c74 Potential buffer overflow --- src/httpd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/httpd.c b/src/httpd.c index de0b39bf..8a45e606 100644 --- a/src/httpd.c +++ b/src/httpd.c @@ -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)); @@ -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)) {