[PATCH] httpd: restore appended index.html also if only CGI is enabled

Fiona Klute via busybox <[email protected]> Thu, 2 Apr 2026 23:08:07 +0200
Newsgroups gmane.linux.busybox
Message-ID <[email protected]>
It is truncated if CONFIG_ENABLE_FEATURE_HTTPD_BASIC_AUTH=y or
CONFIG_ENABLE_FEATURE_HTTPD_CGI=y, but was restored only if
CONFIG_ENABLE_FEATURE_HTTPD_BASIC_AUTH=y, breaking returning
index.html for directory paths if CGI was enabled without Basic Auth.

Result was 404 for /, and for other directories a 200 response
breaking off after headers with -vv logging recording "error: Invalid
argument".

Signed-off-by: Fiona Klute <[email protected]>
---
 networking/httpd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/networking/httpd.c b/networking/httpd.c
index 3b811cb71..ba13cf52d 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -2784,7 +2784,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
 	/* !CGI: it can be only GET or HEAD */
 #endif
 
-#if ENABLE_FEATURE_HTTPD_BASIC_AUTH
+#if ENABLE_FEATURE_HTTPD_BASIC_AUTH || ENABLE_FEATURE_HTTPD_CGI
 	/* Restore truncated .../index.html */
 	if (urlp[-1] == '/')
 		urlp[0] = index_page[0];
-- 
2.53.0