summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--changes-entries/init_request_on_read_failure.txt2
-rw-r--r--server/protocol.c9
2 files changed, 9 insertions, 2 deletions
diff --git a/changes-entries/init_request_on_read_failure.txt b/changes-entries/init_request_on_read_failure.txt
new file mode 100644
index 0000000000..c59bf89460
--- /dev/null
+++ b/changes-entries/init_request_on_read_failure.txt
@@ -0,0 +1,2 @@
+ *) core: Initialize the request fields on read failure to avoid NULLs.
+ [Yann Ylavic] \ No newline at end of file
diff --git a/server/protocol.c b/server/protocol.c
index 276e490528..87056dcda3 100644
--- a/server/protocol.c
+++ b/server/protocol.c
@@ -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));