Commit Graph

965 Commits

Author SHA1 Message Date
d600757e52 SEDERR_TMAMES and SEDERR_TMRMES are used only in sed1.c with 'eval->lnum' as an argument.
'eval' is of type 'struct sed_eval_s' and 'lnum' is an apr_int64_t.

So use APR_INT64_T_FMT format specifier to be more consistent.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897271 13f79535-47bb-0310-9956-ffa450edef68
2022-01-20 21:28:17 +00:00
84aceb715b The format specifier is APR_SIZE_T_FMT, so there is no point in trying to log -1 if apr_file_read() fails, because size_t is unsigned.
It is more straighforward to log the real value returned by apr_file_read() in such a case. The error code is also logged anyway.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897270 13f79535-47bb-0310-9956-ffa450edef68
2022-01-20 21:22:04 +00:00
6aef687d93 * modules/filters/mod_deflate.c (deflate_in_filter): Handle FLUSH in
the input brigade even if done inflating (ctx->done is true), but
  don't try to flush the inflate stream in that case.  (Caught by
  Coverity)

Github: closes #280


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1895552 13f79535-47bb-0310-9956-ffa450edef68
2021-12-03 13:07:42 +00:00
c1a2dfc908 * modules/filters/mod_deflate.c (deflate_out_filter): Catch
apr_bucket_read() errors.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1894152 13f79535-47bb-0310-9956-ffa450edef68
2021-10-12 08:27:15 +00:00
0fd0275c18 * mod_deflate: refrain from reading buckets of known length, just
to get their length. This may transform buckets unwanted (e.g. file
   to mmap) and prevent optimization down the filter chain.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1892728 13f79535-47bb-0310-9956-ffa450edef68
2021-08-30 10:05:06 +00:00
9a7434eb75 Fix a comment (missing '_' in 'keep_body')
While at it, fix some space related style issues  and a doxygen like comment.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1889327 13f79535-47bb-0310-9956-ffa450edef68
2021-04-30 12:40:54 +00:00
587d170151 *) core: provide ap_ssl_* functions in new http_ssl.h header file.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1888083 13f79535-47bb-0310-9956-ffa450edef68
2021-03-26 11:27:34 +00:00
7c5e4c9ab2 Using the new ap_ssl_conn_is_ssl() and ap_ssl_var_lookup() in all internal modules.
* leaving mod_nw_ssl and mod_ssl itself untouched
 * removing mod_ssl.h includes where no longer necessary
 * some modules might skip post_config hooks, but those were left in, even when empty now.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1887364 13f79535-47bb-0310-9956-ffa450edef68
2021-03-09 12:55:55 +00:00
caeb908164 The Microsoft OOXML format uses xml packaged into a zip file, and has
mimetypes like:

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

This mimetypes contains 'xml', but is unfortunately not an xml file.

xml2enc processes these files (in particular, when mod_proxy_html is
used), typically resulting in them being corrupted as it seems to
attempt to perform a ISO-8859-1 to UTF-8 conversion on them.

* modules/filters/mod_xml2enc.c (xml2enc_ffunc): Restrict test for XML
  types to matching "+xml".

Submitted by: Joseph Heenan <joseph.heenan fintechlabs.io>
PR: 64339
Github: closes #150


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1884505 13f79535-47bb-0310-9956-ffa450edef68
2020-12-16 16:23:23 +00:00
5a64355b3f PR#64443: watch whether mod_proxy_html i18n might risk messing up FORM
submission, and insert accept-charset attribute if necessary.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1878553 13f79535-47bb-0310-9956-ffa450edef68
2020-06-06 22:54:32 +00:00
c9ff845120 Move stray /i switch into proper location
This has only been  applied to 2.4.x in r1537823 and never reached trunk

[skip ci]

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1878055 13f79535-47bb-0310-9956-ffa450edef68
2020-05-23 11:13:48 +00:00
11d03dc86a core,modules: provide/use ap_parse_strict_length() helper.
It helps simplifying a lot of duplicated code based on apr_strtoff(), while
also rejecting leading plus/minus signs which are dissalowed in Content-Length
and (Content-)Range headers.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1877954 13f79535-47bb-0310-9956-ffa450edef68
2020-05-20 14:01:17 +00:00
7cd29dcbb5 * modules/filters/mod_proxy_html.c: Fix proxy_html_conf.bufsz
to have correct type, as it is used with ap_set_int_slot.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1876823 13f79535-47bb-0310-9956-ffa450edef68
2020-04-22 11:25:40 +00:00
f461bcf12c Add missing pool tags to help debugging.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1876599 13f79535-47bb-0310-9956-ffa450edef68
2020-04-16 12:32:33 +00:00
c643bc9810 PR64295 cannot override default Virtualhost's mod_reqtimeout
of course only body=n can work the headers have to parsed to get the virtualhost.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1876540 13f79535-47bb-0310-9956-ffa450edef68
2020-04-15 08:51:05 +00:00
eac9bcb41a "?:" is a GNU extension, use standard syntax
spotted by Christophe Jaillet


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1874558 13f79535-47bb-0310-9956-ffa450edef68
2020-02-27 06:59:10 +00:00
46e908f1dc Avoid printing NULL strings in logs
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1874545 13f79535-47bb-0310-9956-ffa450edef68
2020-02-26 17:47:53 +00:00
2766f07d41 Avoid printing NULL strings in logs
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1874346 13f79535-47bb-0310-9956-ffa450edef68
2020-02-22 00:14:49 +00:00
f71e6fc9a3 convert malloc(3) into ap_malloc
bz 64049


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1874156 13f79535-47bb-0310-9956-ffa450edef68
2020-02-18 07:37:45 +00:00
c8f486d716 Follow up to r1873941: define AP_REG_NO_DEFAULT for raw ap_regcomp() usage.
This avoids having to define AP_REG_NO_* for each APR_REG_* specific option,
thus replacing AP_REG_NO_DOTALL introduced lately.

For ap_rxplus_compile() and mod_substitute where default AP_REG_DOTALL is not
suitable, let's use:
    AP_REG_NO_DEFAULT | ap_regcomp_get_default_cflags() & AP_REG_DOLLAR_ENDONLY
to keep the default AP_REG_DOLLAR_ENDONLY unless RegexDefaultOptions unsets it.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1874090 13f79535-47bb-0310-9956-ffa450edef68
2020-02-16 23:08:32 +00:00
85760859ca Fix spelling errors found by codespell. [skip ci]
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1873985 13f79535-47bb-0310-9956-ffa450edef68
2020-02-13 18:15:57 +00:00
b6dd2f55dc don't use DOTALL from mod_substitute which leaves \n at the end of the line.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1873941 13f79535-47bb-0310-9956-ffa450edef68
2020-02-12 13:36:40 +00:00
03d334ebe0 Honor "Accept-Encoding: foo;q=0" as per RFC 7231; which means 'foo' is "not acceptable". PR 58158
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1868313 13f79535-47bb-0310-9956-ffa450edef68
2019-10-11 20:21:14 +00:00
cfa53dbc94 Reverse the order of the test... if clang, then use clang, because some clangs also represent as GNUC.
This fixes breaking the macOS builds due to r1864435 under maint-mode


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1867183 13f79535-47bb-0310-9956-ffa450edef68
2019-09-19 15:50:43 +00:00
963c1c8fac * modules/filters/mod_proxy_html.c, modules/filters/mod_xml2enc.c:
Fix gcc 9 warnings in code attempting to reduce gcc warnings.
  (should have used expat...)

mod_xml2enc.c:26:28: warning: "/*" within comment [-Wcomment]
   26 | /* libxml2 includes unicode/*.h files which uses C++ comments */
      |                             
mod_proxy_html.c:32:28: warning: "/*" within comment [-Wcomment]
   32 | /* libxml2 includes unicode/*.h files which uses C++ comments */
      |                             


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1864464 13f79535-47bb-0310-9956-ffa450edef68
2019-08-06 07:54:24 +00:00
a7eadc31c9 Unfortunately -Wcomment can only be influenced
using a diagnostics pragma starting with GCC 4.6.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1864451 13f79535-47bb-0310-9956-ffa450edef68
2019-08-05 18:31:35 +00:00
5174cd78c1 Follow up to r1864438 and r1864435:
Use the right pragma syntax also in the second file.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1864450 13f79535-47bb-0310-9956-ffa450edef68
2019-08-05 18:05:12 +00:00
dd21b36dbd Use the right pragma syntax.
Follow-up to r1864435.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1864438 13f79535-47bb-0310-9956-ffa450edef68
2019-08-05 14:28:41 +00:00
40581b9391 The GCC flag "-Wno-error=comment" introduced by r1855446
and r1850745 are only known since GCC 4.2. Since it gets
set unconditionally, this breaks compilation with old GCC
even when not using maintainer mode.

Make the fix for maintainer mode more specific by using
a version dependent pragma in the relevant two C files
only switching off error status for comment warnings.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1864435 13f79535-47bb-0310-9956-ffa450edef68
2019-08-05 14:18:22 +00:00
cd58f1856a After reinstatement of DSO support in APR/APR-util, revert r1837437,
r1837435, r1834553, r1833598, r1833452, r1833383, r1833368.

Undoes the following:

mod_ssl: OpenSSL now initializes fully through APR, use that.

mod_ssl: build with LibreSSL.

LibreSSL seems to be openssl-1.1 API compatible only in version 2.8 (master).
So use that for MODSSL_USE_OPENSSL_PRE_1_1_API instead of 2.7, the two 2.7
compatibility-exceptions are handled explicitely but overall it's simpler.

Regarding CRYPTO_malloc_init vs OPENSSL_malloc_init, libreSSL uses none, the
former used to be a no-op but depends is LIBRESSL_INTERNAL in latest versions,
while the latter has never been (and will never be) defined. So don't call any
with LibreSSL.

Follow up to r1833368: share openssl between modules.

Both libapr[-util], the core PRNG, mod_ssl, mod_crypto and mod_session_crypto
can use the same crypto library (e.g. openssl), use the new APR crypto loading
API so that they can work together and initialize/terminate the lib either once
for all or on demand and reusable by the others.

Follow up to r1833368: apr_crypto_prng_after_fork() now used a PID.

Make use of the new apr_crypto_rng API if available.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1861947 13f79535-47bb-0310-9956-ffa450edef68
2019-06-23 21:10:23 +00:00
91f1ba4263 mod_reqtimeout: fix default_[stage]_rate_factor initializations.
r1853901 lowercased the [stage] for MRT_DEFAULT_[stage]_* macros but missed
to change the ones used in reqtimeout_hooks() to initialize the default rate
factors, leading to no default rate in 2.4.39. Fix that now. PR 63325.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1857129 13f79535-47bb-0310-9956-ffa450edef68
2019-04-08 18:46:12 +00:00
b444a8e579 Make the work-around for C++ style comments causing fatal errors in
maintainer-mode for later versions of clang module compile specific
(we will still SEE the errors though when buidlin)


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1855446 13f79535-47bb-0310-9956-ffa450edef68
2019-03-13 17:56:36 +00:00
33bba0cb96 mod_reqtimeout: follow up to r1853901: init stage name outside INIT_STAGE().
It helps both code readability where stages are initilized and potential
logging in the input filter (even if the stage is disabled).


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1853935 13f79535-47bb-0310-9956-ffa450edef68
2019-02-20 08:54:51 +00:00
5160a03ef8 mod_reqtimeout: follow up to r1853901: fix macro args.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1853929 13f79535-47bb-0310-9956-ffa450edef68
2019-02-20 08:13:41 +00:00
94d9347fca mod_reqtimeout: follow up to r1853906: adjust hooks priorities comments.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1853908 13f79535-47bb-0310-9956-ffa450edef68
2019-02-19 18:22:11 +00:00
1416730b40 mod_reqtimeout: Allow to configure (TLS-)handshake timeouts.
The timeouts apply between the process_connection and pre_read_request hooks.
They are disabled by default for compatibily reasons.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1853906 13f79535-47bb-0310-9956-ffa450edef68
2019-02-19 18:14:13 +00:00
445e1f909f mod_reqtimeout: factorize structs and code.
With a bit of macro magic, this is to avoid more code duplication when adding
new stages (next commit will add TLS/handshake timeouts handling in addition to
existing header and body ones).

No functional change here.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1853901 13f79535-47bb-0310-9956-ffa450edef68
2019-02-19 17:21:09 +00:00
062899679d This just got me. I upgraded macOS to Mojave (w/ latest Xcode) and I always build w/ maintainer-mode. The problem is that libxml2 will include various unicode/*.h files that have C++ type comments, which causes building to fail (due to Werror). Work around this.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1850745 13f79535-47bb-0310-9956-ffa450edef68
2019-01-08 13:12:34 +00:00
11bd32e345 Use apr_uint64_t instead of uint64_t; Pointed out by ylavic
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1849630 13f79535-47bb-0310-9956-ffa450edef68
2018-12-23 14:26:06 +00:00
fef7dc6dac Avoid hard-coded "%ld" format strings in mod_deflate's logging statements.
On some platforms (e.g. OpenBSD) zlib's input/output counters are off_t
instead of ulong, which resuls in format-string warnings from some
compilers (e.g. clang). Work around this by upcasting to uint64_t.
Discussed on dev@ with ylavic and wrowe


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1849590 13f79535-47bb-0310-9956-ffa450edef68
2018-12-23 09:26:56 +00:00
d6589774a6 mod_brotli, mod_deflate: Restore the separate handling of 304 Not Modified
responses allowing these modules to properly set or fix-up the response
headers such as Vary or ETag.

This change follows up on r1837056 that disabled that special handling and
thus resulted in a potential violation of RFC7232, 4.1:

   The server generating a 304 response MUST generate any of the following
   header fields that would have been sent in a 200 (OK) response to the
   same request: Cache-Control, Content-Location, Date, ETag, Expires,
   and Vary.)

References:
  https://lists.apache.org/thread.html/f5733ca6743757e8aa8b58a0cd9e27680971551c2a20f5606c66507e@%3Cdev.httpd.apache.org%3E
  https://tools.ietf.org/html/rfc7232#section-4.1

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1843242 13f79535-47bb-0310-9956-ffa450edef68
2018-10-09 12:16:08 +00:00
38e12a1238 * modules/filters/mod_deflate.c
(deflate_out_filter): Fix typo setting output note. (Coverity warning)
  (deflate_in_filter): Fix redundant assignment. (clang warning)


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1842888 13f79535-47bb-0310-9956-ffa450edef68
2018-10-05 10:43:46 +00:00
a920a90838 Axe some redundant conditions. PR 62549.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1837941 13f79535-47bb-0310-9956-ffa450edef68
2018-08-13 12:54:30 +00:00
352e0faebc mod_ratelimit: Don't interfere with "chunked" encoding.
By the time ap_http_header_filter() sends the header brigade and adds the
"CHUNK" filter, we need to garantee that the header went through all the
filters' stack, and more specifically above ap_http_chunk_filter() which
assumes that all it receives is content data.
Since rate_limit_filter() may retain the header brigade, make it run after
ap_http_chunk_filter(), just before AP_FTYPE_CONNECTION filters.

Also, ap_http_header_filter() shouldn't eat the EOS for HEAD/no-body responses.
For instance mod_ratelimit depends on it since r1835168, but any next request
filter may as well to flush and/or bail out approprietely.

This fixes the regression introduced in 2.4.34 (r1835168).
PR 62568.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1837130 13f79535-47bb-0310-9956-ffa450edef68
2018-07-31 10:35:46 +00:00
f673148e9b http: Enforce consistently no response body with both 204 and 304 statuses.
Provide AP_STATUS_IS_HEADER_ONLY() helper/macro to check for 204 or 304 and
use it where some special treatment is needed when no body is expected.

Some of those places handled 204 only.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1837056 13f79535-47bb-0310-9956-ffa450edef68
2018-07-30 13:08:23 +00:00
17c16cc654 mod_ratelimit: fix behavior with proxied content
mod_ratelimit works by splitting data in "chunks"
to send to the client, sleeping a predefined amount
of time between them (200ms). So for example,
a rate-limit 40 value would correspond to a chunk size
of 8192 bytes, flushed to the client every 200ms.

The idea works fine when httpd directly serves the
content, since the filter will be called once with
a single bucket brigade. In the context of a proxied
content though the filter is likely to be called multiple
times, with a bucket brigade size that corresponds to
the maximum allowed buffer size. If this value is lower
or higher than the chunk size, the filter will not
properly rate limit the data going to the client.

This patch solves the problem with two fix:
1) do_sleep is now stored in the ctx context struct,
   so if the filter is invoked multiple times it
   will still sleep when needed. For example, say
   that the chunk_size is 8192 and the bucket brigate
   len is 10240: the filter will flush 8192 bytes
   on the first invocation, sleep 200ms, flush the
   remaining bytes and then finish. The next invocation
   will do the same, clearly not leading to the
   correct "sleeping pattern".
2) The example above highlights also another issue:
   mod_ratelimit should  flush only chunk_size bytes
   at the time (I am now excluding the burst calculation
   from the picture), and buffer between invocations
   unless the brigade contains EOS.

The change has been tested with various scenarios and
it looks working as expected, but of course more
feedback/testing is welcome.

The original patch was written by me and then Yann
refactored the code to be more precise and efficient,
basically transforming an axe in a wonderful Japanese
katana sword, so credits to him for this work.

PR: 62362




git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1833875 13f79535-47bb-0310-9956-ffa450edef68
2018-06-19 22:28:24 +00:00
e6c090ea5a Follow up to r1833368: share openssl between modules.
Both libapr[-util], the core PRNG, mod_ssl, mod_crypto and mod_session_crypto
can use the same crypto library (e.g. openssl), use the new APR crypto loading
API so that they can work together and initialize/terminate the lib either once
for all or on demand and reusable by the others.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1833452 13f79535-47bb-0310-9956-ffa450edef68
2018-06-13 09:54:16 +00:00
2de1c498e7 Save a few cycles.
Use apr_pstrmemdup instead of apr_pstrndup when possible.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1830944 13f79535-47bb-0310-9956-ffa450edef68
2018-05-04 19:54:53 +00:00
20e671b49a Save a few cycles and simlify code.
Use apr_pstrmemdup instead of apr_pstrndup when possible.
Avoid scanning the first 2 bytes when looking for the | delimiter. it is known to be "${".
Avoid comma separated statements, it is not that usual.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1830943 13f79535-47bb-0310-9956-ffa450edef68
2018-05-04 19:51:12 +00:00
e275cc3dc6 mod_proxy_html: Fix variable interpolation and memory allocation failure in ProxyHTMLURLMap.
Proposed by: Ewald Dieterich <ewald mailbox.org>
Reviewed by: ylavic



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1830746 13f79535-47bb-0310-9956-ffa450edef68
2018-05-02 11:32:22 +00:00