merge fixes from RHEL (r1848298, etc)

This commit is contained in:
Joe Orton 2020-08-27 14:00:51 +01:00
parent e862bd87cf
commit cc68ed4869
3 changed files with 145 additions and 1 deletions

View File

@ -0,0 +1,87 @@
# ./pullrev.sh 1848298
http://svn.apache.org/viewvc?view=revision&revision=1848298
https://bugzilla.redhat.com/show_bug.cgi?id=1652493
--- mod_fcgid-2.3.9/modules/fcgid/fcgid_bridge.c
+++ mod_fcgid-2.3.9/modules/fcgid/fcgid_bridge.c
@@ -526,7 +526,8 @@
}
static int add_request_body(request_rec *r, apr_pool_t *request_pool,
- apr_bucket_brigade *output_brigade)
+ apr_bucket_brigade *output_brigade,
+ apr_off_t *body_length)
{
apr_bucket *bucket_input, *bucket_header;
apr_file_t *fd = NULL;
@@ -729,22 +730,49 @@
}
APR_BRIGADE_INSERT_TAIL(output_brigade, bucket_header);
+ *body_length = request_size;
+
return 0;
}
int bridge_request(request_rec * r, int role, fcgid_cmd_conf *cmd_conf)
{
- apr_bucket_brigade *output_brigade;
+ apr_bucket_brigade *output_brigade, *body_brigade;
apr_bucket *bucket_eos;
- char **envp = ap_create_environment(r->pool,
- r->subprocess_env);
+ char **envp;
int rc;
/* Create brigade for the request to fastcgi server */
+ body_brigade
+ = apr_brigade_create(r->pool, r->connection->bucket_alloc);
output_brigade =
apr_brigade_create(r->pool, r->connection->bucket_alloc);
- /* Build the begin request and environ request, append them to output_brigade */
+ /* In responder mode, handle the request body up front to ensure
+ * the content-length is known (even if the request body is
+ * chunked) and sent in the header. */
+ if (role == FCGI_RESPONDER) {
+ apr_off_t body_length;
+
+ rc = add_request_body(r, r->pool, body_brigade, &body_length);
+ if (rc) {
+ return rc;
+ }
+
+ if (body_length && !apr_table_get(r->headers_in, "Content-Length")) {
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+ "mod_fcgid: dechunked request body length %" APR_OFF_T_FMT,
+ body_length);
+
+ apr_table_set(r->subprocess_env, "CONTENT_LENGTH",
+ apr_off_t_toa(r->pool, body_length));
+ apr_table_unset(r->subprocess_env, "HTTP_TRANSFER_ENCODING");
+ }
+ }
+
+ envp = ap_create_environment(r->pool, r->subprocess_env);
+
+ /* Build the begin request and environ request, add them to output_brigade */
if (!build_begin_block
(role, r, r->connection->bucket_alloc, output_brigade)
|| !build_env_block(r, envp, r->connection->bucket_alloc,
@@ -754,12 +782,8 @@
return HTTP_INTERNAL_SERVER_ERROR;
}
- if (role == FCGI_RESPONDER) {
- rc = add_request_body(r, r->pool, output_brigade);
- if (rc) {
- return rc;
- }
- }
+ /* Append the body output. */
+ APR_BRIGADE_CONCAT(output_brigade, body_brigade);
/* The eos bucket now */
bucket_eos = apr_bucket_eos_create(r->connection->bucket_alloc);

View File

@ -0,0 +1,49 @@
diff --git a/modules/fcgid/fcgid_proc_unix.c b/modules/fcgid/fcgid_proc_unix.c
index 218f3f7..8b69a89 100644
--- a/modules/fcgid/fcgid_proc_unix.c
+++ b/modules/fcgid/fcgid_proc_unix.c
@@ -762,14 +762,15 @@ apr_status_t proc_write_ipc(fcgid_ipc *ipc_handle,
struct iovec vec[FCGID_VEC_COUNT];
int nvec = 0;
apr_bucket *e;
+ apr_bucket_brigade* tmpbb = apr_brigade_create(output_brigade->p,output_brigade->bucket_alloc);
- for (e = APR_BRIGADE_FIRST(output_brigade);
- e != APR_BRIGADE_SENTINEL(output_brigade);
- e = APR_BUCKET_NEXT(e)) {
+ while (!APR_BRIGADE_EMPTY(output_brigade)) {
+ e = APR_BRIGADE_FIRST(output_brigade);
apr_size_t len;
const char* base;
if (APR_BUCKET_IS_METADATA(e)) {
+ apr_bucket_delete(e);
continue;
}
@@ -780,6 +781,9 @@ apr_status_t proc_write_ipc(fcgid_ipc *ipc_handle,
return rv;
}
+ APR_BUCKET_REMOVE(e);
+ APR_BRIGADE_INSERT_TAIL(tmpbb, e);
+
vec[nvec].iov_len = len;
vec[nvec].iov_base = (char*) base;
if (nvec == (FCGID_VEC_COUNT - 1)) {
@@ -789,6 +793,7 @@ apr_status_t proc_write_ipc(fcgid_ipc *ipc_handle,
FCGID_VEC_COUNT)) != APR_SUCCESS)
return rv;
nvec = 0;
+ apr_brigade_cleanup(tmpbb);
}
else
nvec++;
@@ -800,6 +805,7 @@ apr_status_t proc_write_ipc(fcgid_ipc *ipc_handle,
return rv;
}
+ apr_brigade_destroy(tmpbb);
return APR_SUCCESS;
}

View File

@ -35,7 +35,7 @@
Name: mod_fcgid Name: mod_fcgid
Version: 2.3.9 Version: 2.3.9
Release: 21%{?dist} Release: 22%{?dist}
Summary: FastCGI interface module for Apache 2 Summary: FastCGI interface module for Apache 2
License: ASL 2.0 License: ASL 2.0
URL: http://httpd.apache.org/mod_fcgid/ URL: http://httpd.apache.org/mod_fcgid/
@ -46,6 +46,8 @@ Source3: mod_fcgid-2.1-README.SELinux
Source4: mod_fcgid-tmpfs.conf Source4: mod_fcgid-tmpfs.conf
Source5: fcgid24.conf Source5: fcgid24.conf
Patch0: mod_fcgid-2.3.4-fixconf-shellbang.patch Patch0: mod_fcgid-2.3.4-fixconf-shellbang.patch
Patch1: mod_fcgid-2.3.9-segfault-upload.patch
Patch2: mod_fcgid-2.3.9-r1848298.patch
BuildRequires: coreutils BuildRequires: coreutils
BuildRequires: gcc BuildRequires: gcc
BuildRequires: httpd-devel >= 2.0 BuildRequires: httpd-devel >= 2.0
@ -76,6 +78,9 @@ cp -p %{SOURCE5} fcgid24.conf
%patch0 -p1 %patch0 -p1
%endif %endif
%patch1 -p1 -b .segfault_upload
%patch2 -p1 -b .r1848298
%build %build
APXS=%{_httpd_apxs} ./configure.apxs APXS=%{_httpd_apxs} ./configure.apxs
make make
@ -127,6 +132,9 @@ install -p -m 644 %{SOURCE4} %{buildroot}%{_tmpfilesdir}/mod_fcgid.conf
%dir %attr(0775,root,apache) %{rundir}/mod_fcgid/ %dir %attr(0775,root,apache) %{rundir}/mod_fcgid/
%changelog %changelog
* Thu Aug 27 2020 Joe Orton <jorton@redhat.com> - 2.3.9-22
- merge fixes from RHEL (r1848298, etc)
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.9-21 * Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.3.9-21
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild