Commit Graph

1265 Commits

Author SHA1 Message Date
1ee7b9348b Follow up to r1740928: including NOT_IN_PROXY in NOT_IN_DIR_LOC_FILE is both
incomplete and not backportable, fix it by introducing NOT_IN_DIR_CONTEXT and
restoring NOT_IN_DIR_LOC_FILE to its previous value.

Per ap_check_cmd_context(), NOT_IN_DIR_LOC_FILE actually/really means "not in
any directory context", while the definition itself does not include all the
existing directory contexts (e.g. <Limit>, or <Proxy> before r1740928).

This is a bit of a misnomer, at least, so instead of (ab)using it by adding the
missing contexts (in an incompatible way), let's define NOT_IN_DIR_CONTEXT to
really exclude all directory context (i.e. NOT_IN_DIR_LOC_FILE + NOT_IN_LIMIT +
NOT_IN_PROXY) and use it wherever NOT_IN_DIR_LOC_FILE was used.

This is by itself a major MMN bump (modules not compiled with this commit and
having directives checked against NOT_IN_DIR_LOC_FILE won't be caught the same
way by NOT_IN_DIR_CONTEXT in the new ap_check_cmd_context() code), but with the
below change, 2.4.x should work as before:

-   if ((forbidden & NOT_IN_DIR_CONTEXT) == NOT_IN_DIR_CONTEXT) {
+   if ((forbidden & NOT_IN_DIR_LOC_FILE) == NOT_IN_DIR_LOC_FILE) {
        if (cmd->path != NULL) {
            return apr_pstrcat(cmd->pool, cmd->cmd->name, gt,
-                           " cannot occur within directory context", NULL);
+                           " cannot occur within <Directory/Location/Files/Proxy> "
+                           "section", NULL);
        }
        ...
    }



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1812193 13f79535-47bb-0310-9956-ffa450edef68
2017-10-14 16:27:14 +00:00
aeaabea3c2 core, mod_rewrite: introduce the 'redirect-keeps-vary' note
to allow proper Vary header insertion when
                   dealing with a RewriteRule in a directory
                   context.

This change is an attempt to fix a long standing problem,
brought up while working on PR 58231. Our documentation clearly
states the following:

"If a HTTP header is used in a condition this header is added
to the Vary header of the response in case the condition
evaluates to true for the request."

This is currently not true for RewriteCond/Rules working in
a directory context, since when an internal redirect happens
all the outstanding response headers get dropped.

There might be a better solution so I am looking forward to
hear more opinions and comments. My goal for a delicate change
like this one would be to affect the least amount of configurations
possible, without triggering unwanted side effects.

If the solution is good for everybody tests will be written
in the suite asap.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1811744 13f79535-47bb-0310-9956-ffa450edef68
2017-10-10 17:41:37 +00:00
81c622d8bf * Silence compiler warning
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1800126 13f79535-47bb-0310-9956-ffa450edef68
2017-06-28 06:50:00 +00:00
99ab47d8ef Since r1753257, "HEAD" method is registered into the registry hash with the M_GET ID.
(r1757672 in 2.4.x)

We iterate over all the values of the registery, so there is no need anymore to have a special case for "HEAD" in  'make_allow()'. It has its own entry now.

With the current code, we have "HEAD" 3 times in the Allow Header field.
This is because we find M_GET 2 times in the registry hash. The first one gives "GET" and "HEAD" (as the special handling), and the second "HEAD" and "HEAD" (as the special handling).


BTW, use APR_ARRAY_PUSH instead of hand coding it, in oder to have the code more readable.

PR 61207

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1799784 13f79535-47bb-0310-9956-ffa450edef68
2017-06-25 06:09:43 +00:00
c18ad646a5 mod_mime: fix quoted pair scanning
Submitted By: ylavic
CVEID: CVE-2017-7679


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1797550 13f79535-47bb-0310-9956-ffa450edef68
2017-06-03 22:04:47 +00:00
f05f006b85 PR60647: ACC per connection not available w/ event MPM
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1780280 13f79535-47bb-0310-9956-ffa450edef68
2017-01-25 22:23:43 +00:00
c34870e09e http: follow up to r1777460.
We MUST unfold outgoing HTTP headers in any case, "message/http" is for
inner content.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1777672 13f79535-47bb-0310-9956-ffa450edef68
2017-01-06 18:04:31 +00:00
4ceaede796 Remove definition of ASCII_CRLF which is the same as CRLF_ASCII.
Remove definition of ASCII_ZERO which is the same as ZERO_ASCII.

Use ZERO_ASCII and CRLF_ASCII in chunk_filter

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1777622 13f79535-47bb-0310-9956-ffa450edef68
2017-01-06 14:57:33 +00:00
157d20dcea http: allow folding in check_headers(), still compliant with RFC 7230 (3.2.4).
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1777460 13f79535-47bb-0310-9956-ffa450edef68
2017-01-05 12:31:48 +00:00
549d1d7627 http_header_filter: on check_headers() failure, use AP_FILTER_ERROR and EOC
semantics to respectively warn the caller and cleanly terminate the connection
afterwards.

Suggested by: rpluem



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1775195 13f79535-47bb-0310-9956-ffa450edef68
2016-12-20 00:58:52 +00:00
60586e25cf http: release data buckets (memory, fd, ...) as soon as possible when
filtered out from the outgoing brigade by ap_http_outerror_filter() applying
the EOC semantic.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1774322 13f79535-47bb-0310-9956-ffa450edef68
2016-12-14 19:16:59 +00:00
2be4a91b59 Follow up to r1773761: restore EOC semantic.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1774286 13f79535-47bb-0310-9956-ffa450edef68
2016-12-14 16:19:05 +00:00
366a562546 Follow up to r1773761: improved recursion detection.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1773865 13f79535-47bb-0310-9956-ffa450edef68
2016-12-12 20:31:44 +00:00
749c178790 Follow up to r1773761: we need to check both ap_send_error_response() and internal redirect recursions.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1773862 13f79535-47bb-0310-9956-ffa450edef68
2016-12-12 19:44:20 +00:00
ce9505bf0b Follow up to r1773761: don't recurse on ap_send_error_response() either.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1773861 13f79535-47bb-0310-9956-ffa450edef68
2016-12-12 19:39:17 +00:00
56ffeebf66 Follow up to r1773761: don't recurse on internal redirects.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1773812 13f79535-47bb-0310-9956-ffa450edef68
2016-12-12 16:14:50 +00:00
64350668a2 Follow up to r1773761: don't check_headers() more than once.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1773779 13f79535-47bb-0310-9956-ffa450edef68
2016-12-12 12:06:06 +00:00
552b23d21e Follow up to r1773293.
When check_headers() fails, clear anything (headers and body) from original/errorneous
response before returning 500.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1773761 13f79535-47bb-0310-9956-ffa450edef68
2016-12-12 10:26:16 +00:00
ffabf5f53e Drop C-L header and message-body from HTTP 204 responses.
The C-L header can be set in a fcgi/cgi backend or in other
filters like ap_content_length_filter (with the value of 0),
meanwhile the message-body can be returned incorrectly
by any backend. The idea is to remove unnecessary bytes
from a HTTP 204 response.

PR 51350


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1773346 13f79535-47bb-0310-9956-ffa450edef68
2016-12-09 09:29:57 +00:00
74b59485b8 change error handling for bad resp headers
- avoid looping between ap_die and the http filter
 - remove the header that failed the check
 - keep calling apr_table_do until our fn stops matching


This is still not great. We get the original body, a 500 status
code and status line.

(r1773285 + fix for first return from check_headers)




git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1773293 13f79535-47bb-0310-9956-ffa450edef68
2016-12-08 19:57:57 +00:00
8763c1b88e revert r1773285
breaks some existing tests. Needs more work.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1773292 13f79535-47bb-0310-9956-ffa450edef68
2016-12-08 19:54:49 +00:00
8f418b2e62 change error handling for bad resp headers
- avoid looping between ap_die and the http filter
 - remove the header that failed the check
 - keep calling apr_table_do until our fn stops matching


This is still not great. We get the original body, a 500 status
code and status line.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1773285 13f79535-47bb-0310-9956-ffa450edef68
2016-12-08 19:34:54 +00:00
0d2dda0d35 After eliminating unusual whitespace in Unsafe mode (e.g. \f \v), we are left
with the same behavior in both of these cases. Simplify. Noted by rpluem.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1773162 13f79535-47bb-0310-9956-ffa450edef68
2016-12-07 23:38:47 +00:00
1597a10583 loop in checking response headers
w/ HTTPProtocolOptions Unsafe


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1772418 13f79535-47bb-0310-9956-ffa450edef68
2016-12-03 00:10:31 +00:00
9858526f1f * Fix numbers count in comment.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1771690 13f79535-47bb-0310-9956-ffa450edef68
2016-11-28 09:04:26 +00:00
afee26bc50 Removing unused warning after r1764961 changes.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1770817 13f79535-47bb-0310-9956-ffa450edef68
2016-11-22 09:51:37 +00:00
c7c184645f remove Location: header checks for absolute URL
https://tools.ietf.org/html/rfc7231#section-7.1.2

   The "Location" header field is used in some responses to refer to a
   specific resource in relation to the response.  The type of
   relationship is defined by the combination of request method and
   status code semantics.

     Location = URI-reference

   The field value consists of a single URI-reference.  When it has the
   form of a relative reference ([RFC3986], Section 4.2), the final
   value is computed by resolving it against the effective request URI
   ([RFC3986], Section 5).


There is even an example with no scheme:

     Location: /People.html#tim



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1770786 13f79535-47bb-0310-9956-ffa450edef68
2016-11-22 01:53:40 +00:00
2ebdeabd30 addendum to r1769760 to make it generate 100 status lines
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1770220 13f79535-47bb-0310-9956-ffa450edef68
2016-11-17 15:43:54 +00:00
ef6e478b78 http: Allow unknown response status' lines returned in the form of:
HTTP/x.x xxx Status xxx



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1769760 13f79535-47bb-0310-9956-ffa450edef68
2016-11-15 09:06:55 +00:00
091f96ee10 Remove unnecessary apr_table_do() function casts
Function casts can cause hard-to-debug corruption issues if a
declaration is accidentally changed to be incompatible. Luckily, most of
the function casts for apr_table_do() calls are unnecessary. Remove
them, and adjust the signatures for helpers that weren't taking void* as
the first argument.

The remaining helper that requires a cast is http_filter.c's
form_header_field(), which is probably where many of these casts were
copy-pasted from. I have left it as-is: it has other direct callers
besides apr_table_do(), and it's already documented with warnings not to
change the function signature.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1769192 13f79535-47bb-0310-9956-ffa450edef68
2016-11-10 20:53:21 +00:00
5b2748e303 Appears we cannot disallow this whitespace, since the chunk BNF coexisted
with the implied *LWS rule, before RFC7230 eliminated the later. Whether
this is actually OWS or BWS is an editorial decision beyond our pay grade.




git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1765475 13f79535-47bb-0310-9956-ffa450edef68
2016-10-18 16:30:43 +00:00
81cdebf482 ap_check_pipeline: clarify/simplify !max_blank_lines logic, no functional change.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1765061 13f79535-47bb-0310-9956-ffa450edef68
2016-10-15 13:31:31 +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
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
1bda0469cf [mod_proxy_]http: follow up to r1750392.
Export [ap_]check_pipeline() and use it also for ap_proxy_check_connection(),
so that all the necessary checks on the connection are done before reusing it.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1756186 13f79535-47bb-0310-9956-ffa450edef68
2016-08-12 13:58:10 +00:00
104ef73c95 Revert r1756064 and r1756060 until fixed (tests framework passes).
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1756065 13f79535-47bb-0310-9956-ffa450edef68
2016-08-11 23:37:45 +00:00
25b8c2b589 http: follow up to r1750392.
Restore AP_MODE_READBYTES cleared inadvertently in r1756060.

[Reverted by r1756065]


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1756064 13f79535-47bb-0310-9956-ffa450edef68
2016-08-11 23:24:47 +00:00
2023d56eea [mod_proxy_]http: follow up to r1750392.
Export [ap_]check_pipeline() and use it also for ap_proxy_check_connection().

[Reverted by r1756065]


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1756060 13f79535-47bb-0310-9956-ffa450edef68
2016-08-11 22:32:42 +00:00
d79b514c4b Fix spelling in comments and text files.
No functional change.
PR 59990


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1756038 13f79535-47bb-0310-9956-ffa450edef68
2016-08-11 19:50:02 +00:00
ea506b6708 A whole lotta nope, if you implement HTCPCP then register your methods in init
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1753263 13f79535-47bb-0310-9956-ffa450edef68
2016-07-18 16:20:27 +00:00
26e6eaab3e Restore 'HEAD' method as a special case of GET with the common ID
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1753257 13f79535-47bb-0310-9956-ffa450edef68
2016-07-18 16:01:21 +00:00
4a87665e53 The method_registry is initialized in register_hooks() for mod_http
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1753245 13f79535-47bb-0310-9956-ffa450edef68
2016-07-18 15:31:39 +00:00
448c82bfd5 Simplify; this code is executed one per request processed, saving
an immeasurably small quantum of CPU of a server under load.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1753223 13f79535-47bb-0310-9956-ffa450edef68
2016-07-18 13:41:26 +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
00e295490d Avoid truncating the_request line when there is no request to 'W'rite.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1743699 13f79535-47bb-0310-9956-ffa450edef68
2016-05-13 16:52:33 +00:00
c9516818c9 Revert 1742822, incorrect assumptions here
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1743511 13f79535-47bb-0310-9956-ffa450edef68
2016-05-12 14:50:09 +00:00
7af0761959 Fix yet another case where we clobber the
server-status request info when a timeout happens.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1742822 13f79535-47bb-0310-9956-ffa450edef68
2016-05-08 13:53:37 +00:00
8c52bb1c1a http: Respond with "408 Request Timeout" when a timeout occurs while
reading the request body.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1739201 13f79535-47bb-0310-9956-ffa450edef68
2016-04-14 21:41:13 +00:00
239ac0c076 Follow up to r1734656: restore c->data_in_input_filters usage to
see if it helps unblocking test framework.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1736216 13f79535-47bb-0310-9956-ffa450edef68
2016-03-22 17:08:29 +00:00
c4cf57c511 reverting r1735176
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1735226 13f79535-47bb-0310-9956-ffa450edef68
2016-03-16 13:00:37 +00:00