[PATCH] httpd should accept trailing slash after PATH_INFO
Denys Vlasenko
vda.linux at googlemail.com
Tue Mar 28 16:59:33 UTC 2023
Fixed in git (a bit differently). Thank you.
On Tue, Mar 7, 2023 at 8:08 PM Andreas Mahling
<andreas.mahling at googlemail.com> wrote:
>
> sorry, it seems I didn't follow the usual path for submitting a patch,
> so here I go again:
>
> 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
>
> --- 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 at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list