aboutsummaryrefslogtreecommitdiff
path: root/networking/httpd.c
diff options
context:
space:
mode:
authorGravatar Denys Vlasenko <vda.linux@googlemail.com>2019-04-16 13:35:56 +0200
committerGravatar Denys Vlasenko <vda.linux@googlemail.com>2019-04-16 13:35:56 +0200
commit2efa726b22e9ebb7ee6c192a0fea0c478a857219 (patch)
tree9fd67fea136bcdf96216434f4371aa7f4a2d883e /networking/httpd.c
parent62ba9e5ac3f158eb36b365af43f8d7d680710963 (diff)
downloadbusybox-2efa726b22e9ebb7ee6c192a0fea0c478a857219.tar.gz
busybox-2efa726b22e9ebb7ee6c192a0fea0c478a857219.tar.bz2
httpd: extract query string only after proxying check
function old new delta handle_incoming_and_exit 2398 2370 -28 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/httpd.c')
-rw-r--r--networking/httpd.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index 7cbf9afef..2b0acd7dc 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -411,7 +411,7 @@ struct globals {
char *rmt_ip_str; /* for $REMOTE_ADDR and $REMOTE_PORT */
const char *bind_addr_or_port;
- const char *g_query;
+ char *g_query;
const char *opt_c_configFile;
const char *home_httpd;
const char *index_page;
@@ -2166,14 +2166,6 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
strcpy(urlcopy, urlp);
/* NB: urlcopy ptr is never changed after this */
- /* Extract url args if present */
- /* g_query = NULL; - already is */
- tptr = strchr(urlcopy, '?');
- if (tptr) {
- *tptr++ = '\0';
- g_query = tptr;
- }
-
#if ENABLE_FEATURE_HTTPD_PROXY
{
int proxy_fd;
@@ -2194,12 +2186,10 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
* When /urlSFX is requested, reverse proxy it
* to http://hostname[:port]/new/pathSFX
*/
- fdprintf(proxy_fd, "%s %s%s%s%s %s\r\n",
+ fdprintf(proxy_fd, "%s %s%s %s\r\n",
prequest, /* "GET" or "POST" */
proxy_entry->url_to, /* "/new/path" */
urlcopy + strlen(proxy_entry->url_from), /* "SFX" */
- (g_query ? "?" : ""), /* "?" (maybe) */
- (g_query ? g_query : ""), /* query string (maybe) */
HTTP_slash /* HTTP/xyz" or "" */
);
cgi_io_loop_and_exit(proxy_fd, proxy_fd, /*max POST length:*/ INT_MAX);
@@ -2207,6 +2197,11 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
}
#endif
+ /* Extract url args if present */
+ g_query = strchr(urlcopy, '?');
+ if (g_query)
+ *g_query++ = '\0';
+
/* Decode URL escape sequences */
tptr = percent_decode_in_place(urlcopy, /*strict:*/ 1);
if (tptr == NULL)