]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_proxy_uwsgi: Error out on HTTP header larger than 16K
authorYann Ylavic <ylavic@apache.org>
Thu, 23 Jul 2020 14:09:50 +0000 (14:09 +0000)
committerYann Ylavic <ylavic@apache.org>
Thu, 23 Jul 2020 14:09:50 +0000 (14:09 +0000)
The uwsgi protocol does not let us serialize more than 16K of HTTP header,
so fail early with 500 if it happens.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1880205 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/proxy/mod_proxy_uwsgi.c

diff --git a/CHANGES b/CHANGES
index bbd6d1ec64ea4627388ef076b9f2f16a3f6e5ed4..87fbed97867ad082a61acc930dec4d2cf4dca9a1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.1
 
+  *) mod_proxy_uwsgi: Error out on HTTP header larger than 16K (hard
+     protocol limit).  [Yann Ylavic]
+
   *) mod_dav: Some DAV extensions, like CalDAV, specify both document
      elements and property elements that need to be taken into account
      when generating a property. The document element and property element
index 87f82a1d4d2bc6a43bef1a468add40ba3eca3c16..3df6ad2475c30dcac26c1034a1fac426190dcda7 100644 (file)
@@ -136,7 +136,7 @@ static int uwsgi_send_headers(request_rec *r, proxy_conn_rec * conn)
     int j;
 
     apr_size_t headerlen = 4;
-    apr_uint16_t pktsize, keylen, vallen;
+    apr_size_t pktsize, keylen, vallen;
     const char *script_name;
     const char *path_info;
     const char *auth;
@@ -178,6 +178,15 @@ static int uwsgi_send_headers(request_rec *r, proxy_conn_rec * conn)
         headerlen += 2 + strlen(env[j].key) + 2 + (env[j].val ? strlen(env[j].val) : 0);
     }
 
+    pktsize = headerlen - 4;
+    if (pktsize > APR_UINT16_MAX) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO()
+                      "can't send headers to %s:%u: packet size too "
+                      "large (%" APR_SIZE_T_FMT ")",
+                      conn->hostname, conn->port, pktsize);
+        return HTTP_INTERNAL_SERVER_ERROR;
+    }
+
     ptr = buf = apr_palloc(r->pool, headerlen);
 
     ptr += 4;
@@ -198,8 +207,6 @@ static int uwsgi_send_headers(request_rec *r, proxy_conn_rec * conn)
         ptr += vallen;
     }
 
-    pktsize = headerlen - 4;
-
     buf[0] = 0;
     buf[1] = (apr_byte_t) (pktsize & 0xff);
     buf[2] = (apr_byte_t) ((pktsize >> 8) & 0xff);