Commit Graph

353 Commits

Author SHA1 Message Date
b2fb7e185c old IBM EBCDIC fix that never got shared.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1777354 13f79535-47bb-0310-9956-ffa450edef68
2017-01-04 18:04:26 +00:00
2b69370fcf Partial port of proposed r1773158 for httpd-2.x only; this change causes all
illegible protocol args to be rejected, irrespective of the strict toggle as
we expect this to occur with a garbage raw SP embedded in the request URI.

Simplifies the code using the protocol 0.9 sentinal to set up an http/1.0
error response.

String duplication of r1773158 is uninteresting, httpd-2.x has a const protocol
member.

Submitted by: rpluem, wrowe



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1773159 13f79535-47bb-0310-9956-ffa450edef68
2016-12-07 23:01:32 +00:00
2e501bbb12 Optimize away one more strchr
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1770869 13f79535-47bb-0310-9956-ffa450edef68
2016-11-22 18:43:28 +00:00
108f897191 List discussion resulted in rejecting all but SP characters in the request
line, but in the strict mode prioritize excessive space testing over bad
space testing (which is captured later) and make both more efficient
(at this test ll[0] is already whitespace or \0 char). Also correct a comment.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1770867 13f79535-47bb-0310-9956-ffa450edef68
2016-11-22 18:33:20 +00:00
84ce5d25db Dropped the never-released ap_has_cntrls() as it had very limited
and inefficient application at that, added ap_scan_vchar_obstext()
to accomplish a similar purpose.

Dropped HttpProtocolOptions StrictURL option, this will be better
handled in the future with a specific directive and perhaps multiple
levels of scrutiny, use ap_scan_vchar_obstext() to simply ensure there
are no control characters or whitespace within the URI.

Changed the scanning of the response header table by check_headers()
to follow the same rulesets as reading request headers. Disallow any
CTL character within a response header value, and any CTL or whitespace
in response header field name, even in strict mode.

Apply HttpProtocolOptions Strict to chunk header parsing, invalid
whitespace is invalid, line termination must follow CRLF convention.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1764961 13f79535-47bb-0310-9956-ffa450edef68
2016-10-14 20:48:43 +00:00
00423058d6 Clarify
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1758313 13f79535-47bb-0310-9956-ffa450edef68
2016-08-30 01:06:48 +00:00
09fcfe627f Calm some overly agressive crlf handling
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1758305 13f79535-47bb-0310-9956-ffa450edef68
2016-08-29 22:19:25 +00:00
28163941ef New optional flag to enforce <CR><LF> line delimiters in ap_[r]getline,
created by overloading 'int fold' (1 or 0) as 'int flags', with the same
value 1 for AP_GETLINE_FOLD (which httpd doesn't use), and a new value
2 for AP_GETLINE_CRLF

Enforce CRLF when HttpProtocolOptions Strict is in force.

Correctly introduces a new t/TEST fail.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1758304 13f79535-47bb-0310-9956-ffa450edef68
2016-08-29 22:17:07 +00:00
b06490c39c Correct the parser construction for several optimizations,
based on the fact that bad whitespace shall not be permitted
or corrected in any operating mode, while preserving the 
ability to extract bad method/uri/proto for later reporting
and diagnostics.

This change causes badwhitespace in the request line or any
request field line to always fail, and not honor the setting
of the HttpProtocolOptions Unsafe option. Mult SP characters
or trailing SP characters in the request line are still 
permitted in Unsafe mode.

Adjusted several error message emits to match these changes.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1758263 13f79535-47bb-0310-9956-ffa450edef68
2016-08-29 17:25:35 +00:00
f54c03b7ee Folding StrictWhitespace into the Strict ruleset of RFC7230, per dev@ poll.
This choice is unanimous, although StrictURI (a different RFC) still hasn't
found absolute concensus.

An ap_mmn bump will follow (major, this removes a struct elt)



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1758226 13f79535-47bb-0310-9956-ffa450edef68
2016-08-29 13:47:27 +00:00
555eebaca2 Revert to the correct APLOGNO ID for this case
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1757924 13f79535-47bb-0310-9956-ffa450edef68
2016-08-26 21:10:08 +00:00
ac07e050c6 Correct URL failure reporting.
Drop the second reporting of HEAD over HTTP/0.9 requests, we short-circuit
this early now in read_request_line() when presented anything other than
the sole "GET" method permitted by spec.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1757921 13f79535-47bb-0310-9956-ffa450edef68
2016-08-26 20:41:55 +00:00
7f78dd0fa0 First survey results, all intrinsicly bad input will be logged at the debug
level, no louder. This patch intentionally dodges the Limit* constrained tests
since administrators may shoot themselves in the foot, or be confronted with
impossibly long cookie values, etc.

Adjust the documentation to match.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1757920 13f79535-47bb-0310-9956-ffa450edef68
2016-08-26 20:35:42 +00:00
c14736b0ac Also catch invalid spaces between the URI <> Protocol in StrictWhitespace mode.
(matching the test for the Method <> URI)



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1757593 13f79535-47bb-0310-9956-ffa450edef68
2016-08-25 02:45:18 +00:00
6cae6f2487 Rename LenientWhitespace to UnsafeWhitespace and change StrictWhitespace
to the default behavior, after discussion with fielding et al about the
purpose of section 3.5. Update the documentation to clarify this.

This patch removes whitespace considerations from the Strict|Unsafe toggle
and consolidates them all in the StrictWhitespace|UnsafeWhitespace toggle.

Added a bunch of logic comments to read_request_line parsing.

Dropped the badwhitespace list for an all-or-nothing toggle in rrl.

Leading space before the method is optimized to be evaluated only once.

Toggled the request from HTTP/0.9 to HTTP/1.0 for more BAD_REQUEST cases.

Moved s/[\n\v\f\r]/ / cleanup logic earlier in the cycle, to operate on
each individual line read, and catch bad whitespace errors earlier.
This changes the obs-fold to more efficiently condense whitespace and
forces concatinatination with a single SP, always. Overrides are not
necessary since obs-fold is clearly deprecated.






git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1757589 13f79535-47bb-0310-9956-ffa450edef68
2016-08-25 01:46:20 +00:00
9d6d6f9fd4 As commented, ensure we don't flag a request as a rejected 0.9 request
if we identified any other parsing errors and handle all 0.9 request
errors as 400 BAD REQUEST, presuming HTTP/1.0 to deliver the error details.
Do not report 0.9 issues as 505 INVALID PROTOCOL because the client apparently
specified no protocol, and 505 post-dates the simple HTTP request mechanism.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1757065 13f79535-47bb-0310-9956-ffa450edef68
2016-08-21 16:50:14 +00:00
b9a6a0ee7b Introduce StrictURI|UnsafeURI for RFC3986 enforcement
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1756959 13f79535-47bb-0310-9956-ffa450edef68
2016-08-19 19:48:58 +00:00
dc0d9fa11e Correct request header handling of whitespace with the new possible config of
HttpProtocolOptions Unsafe StrictWhitespace

I have elected not to preserve any significance to excess whitespace in the
now-deprecated obs-fold code path, that's certainly open for discussion.

This can be reviewed by tweaking t/conf/extra.conf to switch Strict to Unsafe.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1756847 13f79535-47bb-0310-9956-ffa450edef68
2016-08-18 20:26:53 +00:00
464e7d8946 * server/protocol.c (read_request_line): Fix compiler warnings with
GCC.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1756824 13f79535-47bb-0310-9956-ffa450edef68
2016-08-18 15:49:25 +00:00
1877fd6e15 Drop redundant == --rrl_none evaluation, noted by rpluem
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1756823 13f79535-47bb-0310-9956-ffa450edef68
2016-08-18 15:47:23 +00:00
f2035757d3 Drop unused, previously sscanf() target variables
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1756821 13f79535-47bb-0310-9956-ffa450edef68
2016-08-18 15:43:26 +00:00
8d77efe21e Perform correct, strict parsing of the request line, handling the
http protocol tag, url and method appropriately, and attempting 
to extract values even in the presence of unusual whitespace in
keeping with section 3.5, prior to responding with whatever
error reply is needed. Conforms to RFC7230 in all respects,
the section 3.5 optional behavior can be disabled by the user
with a new HttpProtocolOptions StrictWhitespace flag. In all
cases, the_request is regenerated from the parsed components
with exactly two space characters.

Shift sf's 'strict' method check from the Strict behavior because
it violates forward proxy logic, adding a new RegisteredMethods
flag, as it will certainly be useful to some.




git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1756729 13f79535-47bb-0310-9956-ffa450edef68
2016-08-18 07:15:06 +00:00
fc367d65ee Rename the previously undocumented HTTPProtocol directive
to EnforceHTTPProtocol, and invert the default behavior
to strictly observe RFC 7230 unless otherwise configured.
And Document This.

The relaxation option is renamed 'Unsafe'. 'Strict' is no
longer case sensitive. 'min=0.9|1.0' is now the verbose
'Allow0.9' or 'Require1.0' case-insenstive grammer. The
exclusivity tests have been modified to detect conflicts.

The 'strict,log' option failed to enforce strict conformance,
and has been removed. Unsafe, informational logging is possible
in any loadable module, after the request data is unsafely
accepted.

This triggers a group of failures in t/apache/headers.t as
expected since those patterns violated RFC 7230 section 3.2.4.




git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1756540 13f79535-47bb-0310-9956-ffa450edef68
2016-08-16 18:11:14 +00:00
705d42f5f6 Follow on to r1755264, for the case of merged header length exceptions,
and ensure the field header name is truncated to a sane log width.

  Stop reflecting irrelevant data to the request error notes, particularly
  for abusive and malformed traffic the non-technical consumer of a user-agent
  has no control over.

  Simply take note where the administrator-configured limits have been exceeded,
  that administrator can find details in the error log if desired.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755744 13f79535-47bb-0310-9956-ffa450edef68
2016-08-10 13:39:35 +00:00
e62f035172 Follow up to r1755264.
Don't crash when ap_rgetline() returns a NULL field on ENOSPC.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755343 13f79535-47bb-0310-9956-ffa450edef68
2016-08-05 15:08:24 +00:00
eebd8e8076 Stop reflecting irrelevant data to the request error notes, particularly
for abusive and malformed traffic the non-technical consumer of a user-agent
has no control over.

Simply take note where the administrator-configured limits have been exceeded,
that administrator can find details in the error log if desired.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755264 13f79535-47bb-0310-9956-ffa450edef68
2016-08-05 09:13:26 +00:00
61c3d59936 Treat an empty obs-fold line as abusive traffic
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755263 13f79535-47bb-0310-9956-ffa450edef68
2016-08-05 09:08:35 +00:00
b45b9ff116 Strictly observe the one-SP requirement of every obs-fold line.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755236 13f79535-47bb-0310-9956-ffa450edef68
2016-08-04 21:43:01 +00:00
3a8a5da727 Now eliminate all intra-obs-fold excess whitespace, results condensed per spec.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755235 13f79535-47bb-0310-9956-ffa450edef68
2016-08-04 20:51:49 +00:00
3906397903 An empty obs-fold line is a no-op.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755234 13f79535-47bb-0310-9956-ffa450edef68
2016-08-04 20:48:52 +00:00
e0a32d9c60 As promised, reduce this logic by net 9 code lines, shifting the burden
of killing trailing whitespace to the purpose-agnostic read logic.

Whitespace before or after an obs-fold, and before or after a field value
have no semantic purpose at all. Because we are building a buffer for all
folded values, reducing the size of the newly allocated buffer is always
to our advantage.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755233 13f79535-47bb-0310-9956-ffa450edef68
2016-08-04 20:46:45 +00:00
edd78a4931 Another comment for reviewers to follow
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755126 13f79535-47bb-0310-9956-ffa450edef68
2016-08-03 23:17:07 +00:00
46f1b60ff3 Testing len > 0 is redundant when *field is a "\0" and mismatches here,
folded flag was a no-op, unused once we added continue; logic.
Fix these as initially attempted in r1755114.

Add some comments to make this code slightly more legible to the reviewer.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755125 13f79535-47bb-0310-9956-ffa450edef68
2016-08-03 23:07:55 +00:00
a37ee2d35d Reformat for indentation following r1755123, Whitespace Only
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755124 13f79535-47bb-0310-9956-ffa450edef68
2016-08-03 22:58:10 +00:00
078ccbe978 Clean up an edge case where obs-fold continuation preceeds the first header,
as with r1755098, but this time ensure the previous header processing logic 
ensures there was a previous header as identified by jchampion.

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@1755123 13f79535-47bb-0310-9956-ffa450edef68
2016-08-03 22:42:26 +00:00
3283ba38a9 Revert to r1754577 based on last_field NULL on first-pass defect
noted by Jacob Champion, discarding my work of today.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755118 13f79535-47bb-0310-9956-ffa450edef68
2016-08-03 21:51:04 +00:00
a4b5efa1ac C89 fix, caught by Jacob Champion
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755116 13f79535-47bb-0310-9956-ffa450edef68
2016-08-03 21:40:12 +00:00
cf5d664cf7 Improve comments for reviewers to understand this logic
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755115 13f79535-47bb-0310-9956-ffa450edef68
2016-08-03 21:38:12 +00:00
5f7565364f Testing len > 0 is redundant when *field is a "\0" and mismatches here.
folded flag was a no-op, unused once we added continue; logic.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755114 13f79535-47bb-0310-9956-ffa450edef68
2016-08-03 21:18:12 +00:00
671d9cbe97 Whitespace-only followup after r1755098 logic patch
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755099 13f79535-47bb-0310-9956-ffa450edef68
2016-08-03 16:59:21 +00:00
0a8addebb0 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.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1755098 13f79535-47bb-0310-9956-ffa450edef68
2016-08-03 16:46:20 +00:00
04a85817d0 Correct logic, detect no 'token' chars, or missing ':'
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1754577 13f79535-47bb-0310-9956-ffa450edef68
2016-07-29 21:47:19 +00:00
0e1efad087 Correct usage for ap_scan_http_token (had used _get_ syntax), noted by Rüdiger
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1754570 13f79535-47bb-0310-9956-ffa450edef68
2016-07-29 20:22:37 +00:00
7ba8fc003a Clean up doubled-'{'
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1754569 13f79535-47bb-0310-9956-ffa450edef68
2016-07-29 20:12:38 +00:00
853d9c412d Introduce ap_scan_http_token / ap_scan_http_field_content for a much
more efficient pass through the header text; rather than reparsing
the strings over and over under the HTTP_CONFORMANCE_STRICT fules.

Improve logic and legibility by eliminating multiple repetitive tests
of the STRICT flag, and simply reorder 'classic' behavior first and
this new parser second to simplify the diff. Because of the whitespace
change (which I had wished to dodge), reading this --ignore-all-space
is a whole lot easier. Particularly against 2.4.x branch, which is now
identical in the 'classic' logic flow. Both of which I'll share with dev@



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1754556 13f79535-47bb-0310-9956-ffa450edef68
2016-07-29 17:37:41 +00:00
3987f79eb6 Strictly observe spec on obs-fold
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1754548 13f79535-47bb-0310-9956-ffa450edef68
2016-07-29 16:24:14 +00:00
e0fb12bf49 We arrive here for more than one cause; offer a more general statement
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1754547 13f79535-47bb-0310-9956-ffa450edef68
2016-07-29 16:20:40 +00:00
81b4949306 core: removing quirk for supressing h2 in Upgrade: response header, never backported, obsolete
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1748591 13f79535-47bb-0310-9956-ffa450edef68
2016-06-15 14:47:21 +00:00
f4cc76ee71 Rename ap_casecmpstr[n]() to ap_cstr_casecmp[n](), update with APR doxygen
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1747469 13f79535-47bb-0310-9956-ffa450edef68
2016-06-09 00:06:42 +00:00
5957e68d5e Delay a table lookup until we know that we can handle the request.
Concat a string at compile time, rather than run time.
Some various style fixes.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1746884 13f79535-47bb-0310-9956-ffa450edef68
2016-06-05 09:17:33 +00:00