httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r1755098 - in /httpd/httpd/trunk: docs/log-message-tags/next-number server/protocol.c
Date Wed, 03 Aug 2016 16:46:21 GMT
Author: wrowe
Date: Wed Aug  3 16:46:20 2016
New Revision: 1755098

URL: http://svn.apache.org/viewvc?rev=1755098&view=rev
Log:
Clean up an edge case where obs-fold continuation preceeds the first header.

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.


Modified:
    httpd/httpd/trunk/docs/log-message-tags/next-number
    httpd/httpd/trunk/server/protocol.c

Modified: httpd/httpd/trunk/docs/log-message-tags/next-number
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/log-message-tags/next-number?rev=1755098&r1=1755097&r2=1755098&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/log-message-tags/next-number (original)
+++ httpd/httpd/trunk/docs/log-message-tags/next-number Wed Aug  3 16:46:20 2016
@@ -1 +1 @@
-3442
+3443

Modified: httpd/httpd/trunk/server/protocol.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/protocol.c?rev=1755098&r1=1755097&r2=1755098&view=diff
==============================================================================
--- httpd/httpd/trunk/server/protocol.c (original)
+++ httpd/httpd/trunk/server/protocol.c Wed Aug  3 16:46:20 2016
@@ -835,8 +835,15 @@ AP_DECLARE(void) ap_get_mime_headers_cor
             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_cor
                 }
                 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_cor
                  */
                 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) {



Mime
View raw message