The memory pointed to by g_query gets overwritten when the index_page
is used, causing URL arguments to get dropped when we fall back to
/cgi-bin/index.cgi.

Work around it by making g_query a deep copy of urlp when CGI support
is enabled, rather than silently dropping them.

Signed-off-by: Peter Korsgaard <[email protected]>
---
 networking/httpd.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/networking/httpd.c b/networking/httpd.c
index 0356e4c..37d6577 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1996,7 +1996,14 @@ static void handle_incoming_and_exit(const 
len_and_sockaddr *fromAddr)
        tptr = strchr(urlcopy, '?');
        if (tptr) {
                *tptr++ = '\0';
+#if ENABLE_FEATURE_HTTPD_CGI
+               /* tptr gets overwritten by index_page, so do deep copy
+                  for /cgi-bin/index.cgi */
+               g_query = alloca(strlen(tptr) + 1);
+               strcpy((char *)g_query, tptr);
+#else
                g_query = tptr;
+#endif
        }
 
        /* Decode URL escape sequences */
@@ -2265,8 +2272,6 @@ static void handle_incoming_and_exit(const 
len_and_sockaddr *fromAddr)
                /* It's a dir URL and there is no index.html
                 * Try cgi-bin/index.cgi */
                if (access("/cgi-bin/index.cgi"+1, X_OK) == 0) {
-                       urlp[0] = '\0';
-                       g_query = urlcopy;
                        send_cgi_and_exit("/cgi-bin/index.cgi", prequest, 
length, cookie, content_type);
                }
        }
-- 
1.7.7.1

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to