]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
core: Initialize the request fields on read failure to avoid NULLs.
authorYann Ylavic <ylavic@apache.org>
Tue, 7 Sep 2021 13:00:06 +0000 (13:00 +0000)
committerYann Ylavic <ylavic@apache.org>
Tue, 7 Sep 2021 13:00:06 +0000 (13:00 +0000)
* server/protocol.c(read_request_line):
  Set r->method_number to M_INVALID and r->{method,uri,unparsed_uri} to "-"
  when read fails, ap_parse_request_line() will never be called.

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

changes-entries/init_request_on_read_failure.txt [new file with mode: 0644]
server/protocol.c

diff --git a/changes-entries/init_request_on_read_failure.txt b/changes-entries/init_request_on_read_failure.txt
new file mode 100644 (file)
index 0000000..c59bf89
--- /dev/null
@@ -0,0 +1,2 @@
+  *) core: Initialize the request fields on read failure to avoid NULLs.
+     [Yann Ylavic]
\ No newline at end of file
index 276e4905281306cebc2c0529aba2291630641d15..87056dcda3998d1db405ca03f65732803f5a929a 100644 (file)
@@ -716,6 +716,13 @@ static int read_request_line(request_rec *r, apr_bucket_brigade *bb)
         if (rv != APR_SUCCESS) {
             r->request_time = apr_time_now();
 
+            /* Fall through with an invalid (non NULL) request */
+            r->method = "-";
+            r->method_number = M_INVALID;
+            r->uri = r->unparsed_uri = apr_pstrdup(r->pool, "-");
+            r->proto_num = HTTP_VERSION(1,0);
+            r->protocol  = "HTTP/1.0";
+
             /* ap_rgetline returns APR_ENOSPC if it fills up the
              * buffer before finding the end-of-line.  This is only going to
              * happen if it exceeds the configured limit for a request-line.
@@ -732,8 +739,6 @@ static int read_request_line(request_rec *r, apr_bucket_brigade *bb)
             else if (APR_STATUS_IS_EINVAL(rv)) {
                 r->status = HTTP_BAD_REQUEST;
             }
-            r->proto_num = HTTP_VERSION(1,0);
-            r->protocol  = "HTTP/1.0";
             return 0;
         }
     } while ((len <= 0) && (--num_blank_lines >= 0));