summaryrefslogtreecommitdiff
path: root/usr.sbin/httpd
diff options
context:
space:
mode:
authorYASUOKA Masahiko <yasuoka@cvs.openbsd.org>2020-09-12 07:34:18 +0000
committerYASUOKA Masahiko <yasuoka@cvs.openbsd.org>2020-09-12 07:34:18 +0000
commit518d7e02e4673edfa16c13a28b7cecb1cac01847 (patch)
treeb9310379ba3481a6142e29d0262d6376152b6924 /usr.sbin/httpd
parent99685bc85f8fe9e90f32a3cde0ff26458bc13b4b (diff)
Use the original requested URI for REQUEST_URI.
ok millert florian
Diffstat (limited to 'usr.sbin/httpd')
-rw-r--r--usr.sbin/httpd/http.h3
-rw-r--r--usr.sbin/httpd/server_fcgi.c6
-rw-r--r--usr.sbin/httpd/server_http.c12
3 files changed, 14 insertions, 7 deletions
diff --git a/usr.sbin/httpd/http.h b/usr.sbin/httpd/http.h
index 5c877a639b7..b9f21b85915 100644
--- a/usr.sbin/httpd/http.h
+++ b/usr.sbin/httpd/http.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: http.h,v 1.15 2019/05/08 21:41:06 tb Exp $ */
+/* $OpenBSD: http.h,v 1.16 2020/09/12 07:34:17 yasuoka Exp $ */
/*
* Copyright (c) 2012 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -246,6 +246,7 @@ struct http_descriptor {
/* Rewritten path and query remain NULL if not used */
char *http_path_alias;
char *http_query_alias;
+ char *http_path_orig;
/* A tree of headers and attached lists for repeated headers. */
struct kv *http_lastheader;
diff --git a/usr.sbin/httpd/server_fcgi.c b/usr.sbin/httpd/server_fcgi.c
index ac841c10e05..8d3b581568f 100644
--- a/usr.sbin/httpd/server_fcgi.c
+++ b/usr.sbin/httpd/server_fcgi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server_fcgi.c,v 1.83 2020/08/24 15:49:11 tracey Exp $ */
+/* $OpenBSD: server_fcgi.c,v 1.84 2020/09/12 07:34:17 yasuoka Exp $ */
/*
* Copyright (c) 2014 Florian Obser <florian@openbsd.org>
@@ -299,13 +299,13 @@ server_fcgi(struct httpd *env, struct client *clt)
}
if (!desc->http_query) {
- if (fcgi_add_param(&param, "REQUEST_URI", desc->http_path,
+ if (fcgi_add_param(&param, "REQUEST_URI", desc->http_path_orig,
clt) == -1) {
errstr = "failed to encode param";
goto fail;
}
} else {
- if (asprintf(&str, "%s?%s", desc->http_path,
+ if (asprintf(&str, "%s?%s", desc->http_path_orig,
desc->http_query) == -1) {
errstr = "failed to encode param";
goto fail;
diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c
index fc8ec226db9..35194009efc 100644
--- a/usr.sbin/httpd/server_http.c
+++ b/usr.sbin/httpd/server_http.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server_http.c,v 1.140 2020/08/03 10:59:53 benno Exp $ */
+/* $OpenBSD: server_http.c,v 1.141 2020/09/12 07:34:17 yasuoka Exp $ */
/*
* Copyright (c) 2006 - 2018 Reyk Floeter <reyk@openbsd.org>
@@ -100,6 +100,8 @@ server_httpdesc_free(struct http_descriptor *desc)
free(desc->http_path);
desc->http_path = NULL;
+ free(desc->http_path_orig);
+ desc->http_path_orig = NULL;
free(desc->http_path_alias);
desc->http_path_alias = NULL;
free(desc->http_query);
@@ -1204,9 +1206,13 @@ server_response(struct httpd *httpd, struct client *clt)
char *hostval, *query;
const char *errstr = NULL;
- /* Decode the URL */
+ /* Preserve original path */
if (desc->http_path == NULL ||
- url_decode(desc->http_path) == NULL)
+ (desc->http_path_orig = strdup(desc->http_path)) == NULL)
+ goto fail;
+
+ /* Decode the URL */
+ if (url_decode(desc->http_path) == NULL)
goto fail;
/* Canonicalize the request path */