]> granicus.if.org Git - apache/commitdiff
Reject requests containing (invalid) NULL characters in request line
authorNick Kew <niq@apache.org>
Mon, 21 Dec 2009 00:40:07 +0000 (00:40 +0000)
committerNick Kew <niq@apache.org>
Mon, 21 Dec 2009 00:40:07 +0000 (00:40 +0000)
or request headers.
PR 43039

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

CHANGES
server/protocol.c

diff --git a/CHANGES b/CHANGES
index d4a6f08083970691eaf0061c2518c211fedf7ad7..1dc2518400c227db21705ed61ca7984a636bf995 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -19,6 +19,9 @@ Changes with Apache 2.3.5
      a new request.
      PR 47087 [Nick Kew]
 
+  *) Core: reject NULLs in request line or request headers.
+     PR 43039 [Nick Kew]
+
 Changes with Apache 2.3.4
 
   *) Replace AcceptMutex, LockFile, RewriteLock, SSLMutex, SSLStaplingMutex,
index 11040f32a7646ef0fac539478d202a67e12e8f70..b5e4a1ce02b72cda5cf207ff34c58e14476db747 100644 (file)
@@ -431,8 +431,13 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
             }
         }
     }
-
     *read = bytes_handled;
+
+    /* PR#43039: We shouldn't accept NULL bytes within the line */
+    if (strlen(*s) < bytes_handled - 1) {
+        return APR_EINVAL;
+    }
+
     return APR_SUCCESS;
 }
 
@@ -609,6 +614,9 @@ static int read_request_line(request_rec *r, apr_bucket_brigade *bb)
             else if (rv == APR_TIMEUP) {
                 r->status = HTTP_REQUEST_TIME_OUT;
             }
+            else if (rv == APR_EINVAL) {
+                r->status = HTTP_BAD_REQUEST;
+            }
             return 0;
         }
     } while ((len <= 0) && (++num_blank_lines < max_blank_lines));
@@ -897,9 +905,16 @@ request_rec *ap_read_request(conn_rec *conn)
 
     /* Get the request... */
     if (!read_request_line(r, tmp_bb)) {
-        if (r->status == HTTP_REQUEST_URI_TOO_LARGE) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
-                          "request failed: URI too long (longer than %d)", r->server->limit_req_line);
+        if (r->status == HTTP_REQUEST_URI_TOO_LARGE
+            || r->status == HTTP_BAD_REQUEST) {
+            if (r->status == HTTP_BAD_REQUEST) {
+                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                              "request failed: invalid characters in URI");
+            }
+            else {
+                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                              "request failed: URI too long (longer than %d)", r->server->limit_req_line);
+            }
             ap_send_error_response(r, 0);
             ap_update_child_status(conn->sbh, SERVER_BUSY_LOG, r);
             ap_run_log_transaction(r);