]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Clean up an edge case where obs-fold continuation preceeds the first header.
authorWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 3 Aug 2016 16:46:20 +0000 (16:46 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 3 Aug 2016 16:46:20 +0000 (16:46 +0000)
This patch restructures the loop for legibility with a loop continuation,
allowing us to flatten all of this hard-to-follow code. The subsequent
patch will be a whitespace-only change for formatting.

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

docs/log-message-tags/next-number
server/protocol.c

index b3d97ff871b345d3908ec894eead4f12cf36882e..b65d63da78bf08a4c4d3aad71d827ec4c7aee4d3 100644 (file)
@@ -1 +1 @@
-3442
+3443
index 60be6fb12ae6f74e2d4c274c37b5773de25a7435..7f057b6059ab36588a297eed61b291e85cd28bae 100644 (file)
@@ -835,8 +835,15 @@ AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb
             return;
         }
 
-        if (last_field != NULL) {
-            if ((len > 0) && ((*field == '\t') || *field == ' ')) {
+        if ((len > 0) && ((*field == '\t') || *field == ' ')) {
+            if (last_field == NULL) {
+                r->status = HTTP_BAD_REQUEST;
+                ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(03442)
+                              "Line folding encounterd before first"
+                              " header line");
+                return;
+            }
+
                 /* This line is a continuation of the preceding line(s),
                  * so append it to the line that we've set aside.
                  * Note: this uses a power-of-two allocator to avoid
@@ -885,8 +892,10 @@ AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb
                 }
                 last_len += len;
                 folded = 1;
-            }
-            else /* not a continuation line */ {
+                continue;
+        }
+
+                /* not a continuation line */
 
                 if (r->server->limit_req_fields
                     && (++fields_read > r->server->limit_req_fields)) {
@@ -1009,8 +1018,7 @@ AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb
                  */
                 alloc_len = 0;
 
-            } /* end if current line is not a continuation starting with tab */
-        }
+        /* end of logic where current line was not a continuation line */
 
         /* Found a blank line, stop. */
         if (len == 0) {