[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    httpd should accept trailing slash after PATH_INFO
From:       Andreas Mahling <andreas.mahling () googlemail ! com>
Date:       2023-03-07 18:53:31
Message-ID: CAF6j0WDj3tb=WoaCfvCf5S2MGjbpLh=wNQjEo2fERSFTtjTfDw () mail ! gmail ! com
[Download RAW message or body]

hello,

I stumbled upon a problem with the CGI-enabled httpd. It seems that
httpd can't handle a CGI call with an appended PATH_INFO, if the
latter ends with a slash. httpd takes this as a call for a directory
listing and throws 404.

For further details you may take a look here:
https://lists.zx2c4.com/pipermail/cgit/2023-March/004825.html

I've attached a patch, which works for me, although my understanding
of the httpd.c code is only superficial.

Patch was generated by
diff -u networking/httpd.c networking/httpd.c.new >httpd.patch
against the busybox-1.34.1 tarball

Thanks a lot to the busybox developers for their outstanding work.

best regards
Andreas

["httpd.patch" (text/x-patch)]

--- networking/httpd.c	2021-06-16 12:02:16.000000000 +0200
+++ networking/httpd.c.new	2023-03-07 19:05:22.447075000 +0100
@@ -2426,11 +2426,14 @@
 	}
 #if ENABLE_FEATURE_HTTPD_CGI
 	else if (urlp[-1] == '/') {
-		/* It's a dir URL and there is no index.html */
-		/* Is there cgi-bin/index.cgi? */
-		if (access("/cgi-bin/index.cgi"+1, X_OK) != 0)
-			send_headers_and_exit(HTTP_NOT_FOUND); /* no */
-		cgi_type = CGI_INDEX;
+		if (cgi_type == CGI_NONE) {
+			/* It's a dir URL and there is no index.html */
+			/* Is there cgi-bin/index.cgi? */
+			if (access("/cgi-bin/index.cgi"+1, X_OK) != 0) {
+				send_headers_and_exit(HTTP_NOT_FOUND); /* no */
+			}
+			cgi_type = CGI_INDEX;
+		}
 	}
 #endif
 


_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic