Commit Graph

5151 Commits

Author SHA1 Message Date
e8da666beb * server/util_expr_parse.c (yyparse): Fix typo in comment.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1915543 13f79535-47bb-0310-9956-ffa450edef68
2024-02-02 14:49:06 +00:00
8268915c90 Updated typo NWGNUmakefile
dependencies was spelled dependancies.

Submitted by: StevenSedwick <133059415+StevenSedwick@users.noreply.github.com>

Github: closes #382


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1915380 13f79535-47bb-0310-9956-ffa450edef68
2024-01-24 14:44:49 +00:00
97a1873332 regex: Add AP_REG_NOTEMPTY_ATSTART maching option.
* include/ap_mmn.h:
  Bump MMN minor.

* include/ap_regex.h:
  Define AP_REG_NOTEMPTY_ATSTART bit.

* server/util_pcre.c(ap_regexec_ex):
  Map AP_REG_NOTEMPTY_ATSTART to native PCRE_NOTEMPTY_ATSTART.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1915268 13f79535-47bb-0310-9956-ffa450edef68
2024-01-16 16:56:58 +00:00
e52a206008 regex: Add ap_regexec_ex() which can take a starting offset to match from.
* include/ap_mmn.h:
  Bump MMN minor.

* include/ap_regex.h:
  Declare ap_regexec_ex().

* server/util_pcre.c(ap_regexec, ap_regexec_len, ap_regexec_ex):
  Reuse existing ap_regexec_len() code to implement ap_regexec_ex() where the
  offset is given instead of zero, then implement ap_regexec{,len}() in terms
  of ap_regexec_ex().



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1915267 13f79535-47bb-0310-9956-ffa450edef68
2024-01-16 16:51:03 +00:00
b24195a1f2 util_filter: More useful logging for brigade setaside/reinstate/adopt.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910846 13f79535-47bb-0310-9956-ffa450edef68
2023-07-07 11:00:34 +00:00
ece6bf4363 http_protocol: make request processing more robust for incomplete data
- Length restrictions may error on a too long request path, leaving
  the uri unset.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910533 13f79535-47bb-0310-9956-ffa450edef68
2023-06-21 12:08:06 +00:00
f3004c8956 *) http_protocol: if there is a request and an error bucket in the input
brigade, always process the request bucket first. This gives the proper
     context in which to evaluate the error bucket in.
     Some error access r->method, for example, in their response body.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910530 13f79535-47bb-0310-9956-ffa450edef68
2023-06-21 09:49:13 +00:00
3ed9d65b05 *) mod_http2: added support for bootstrapping WebSockets via HTTP/2, as
described in RFC 8441. A new directive 'H2WebSockets on|off' has been
     added. The feature is by default not enabled.
     As also discussed in the manual, this feature should work for setups
     using "ProxyPass backend-url upgrade=websocket" without further changes.
     Special server modules for WebSockets will have to be adapted,
     most likely, as the handling if IO events is different with HTTP/2.
     HTTP/2 WebSockets are supported on platforms with native pipes. This
     excludes Windows.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910507 13f79535-47bb-0310-9956-ffa450edef68
2023-06-20 12:01:09 +00:00
ba808b06f3 * Fix copy and paste error
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910324 13f79535-47bb-0310-9956-ffa450edef68
2023-06-09 11:18:02 +00:00
bbe60a5b3d When we are at flush_max_threshold and the next bucket is a metadata (i.e. next->length == 0), we still need to re-check for flush_max_threshold and associated optimisation (is_in_memory_bucket()) when we process this metadata bucket in the next iteration of the loop.
Follow-up to r1892450.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1909966 13f79535-47bb-0310-9956-ffa450edef68
2023-05-21 17:46:22 +00:00
4fc2fd7dd5 Make sources build with latest clang version
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1909450 13f79535-47bb-0310-9956-ffa450edef68
2023-04-27 07:14:36 +00:00
3e638ff283 core: Add the token_checker hook, that allows authentication to take
place using mechanisms other than username/password, such as bearer
tokens.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1909409 13f79535-47bb-0310-9956-ffa450edef68
2023-04-25 17:35:08 +00:00
2f09e388bf Follow up to r1909356: c89/style fix.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1909368 13f79535-47bb-0310-9956-ffa450edef68
2023-04-23 20:44:21 +00:00
7b12bfc7fe core: Restore original regex value when nesting Location,
Directory and File directives.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1909356 13f79535-47bb-0310-9956-ffa450edef68
2023-04-22 18:10:30 +00:00
1925882d55 core: Be explicit if an enclosing directive contains a path or a
regex.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1909135 13f79535-47bb-0310-9956-ffa450edef68
2023-04-14 14:02:11 +00:00
24007faa4f Fix possible NULL pointer dereference casued by apreq_param_make()
The function apreq_param_make() will return NULL on failure. However
NULL check are forgetten before derenference, which could lead to
NULL pointer dereference.

Adding NULL check to all use of apreq_param_make().

Submitted by: Zhou Qingyang <zhou1615@umn.edu>

Github: closes #303


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908981 13f79535-47bb-0310-9956-ffa450edef68
2023-04-05 06:38:18 +00:00
076ee6f967 mpm_event: useful APLOG_DEBUG messages.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908883 13f79535-47bb-0310-9956-ffa450edef68
2023-04-01 08:43:49 +00:00
4599b709bb Fix a possible null pointer dereference in ap_expr_parse()
In ap_expr_parse(), ap_expr_yylex_init() will return 1 on failure,
and ctx.scanner will remain NULL. However the return value of
ap_expr_yylex_init() is not checked, and there is a dereference of
ctx.scanner in following function ap_expr_yyset_extra(),
which may lead to NULL pointer dereference.

Fix this bug by adding return value check of ap_expr_yylex_init.

Submitted by: Zhou Qingyang <zhou1615@umn.edu>

Github: closes #308


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908772 13f79535-47bb-0310-9956-ffa450edef68
2023-03-28 21:12:47 +00:00
2133fa3a38 check apreq_cookie_make return value
Github: closes #302


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908673 13f79535-47bb-0310-9956-ffa450edef68
2023-03-23 16:23:12 +00:00
008a9bc99f util_time: Follow up to r1908380 and r1908389: apr_strings.h not needed anymore.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908556 13f79535-47bb-0310-9956-ffa450edef68
2023-03-20 10:47:05 +00:00
11eb5a312d core: Follow up to r1908393: comment about where ap_server_conf is set.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908406 13f79535-47bb-0310-9956-ffa450edef68
2023-03-15 10:42:57 +00:00
f0747086ec core: Follow up to r1908393: ap_server_conf to NULL before ap_read_config().
Just to be sure..



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908394 13f79535-47bb-0310-9956-ffa450edef68
2023-03-14 16:01:14 +00:00
feb15a2eb5 core: Set ap_server_conf ASAP.
* server/config.c(ap_read_config):
  Set ap_server_conf as soon as it exists (with defaults).

* server/main.c(main):
  Now that ap_server_conf is set by ap_read_config(), just make
  sure it's not NULL afterward with an ap_assert()ion.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908393 13f79535-47bb-0310-9956-ffa450edef68
2023-03-14 15:48:41 +00:00
d51326e797 log: Follow up to r1908388: ap_server_conf might be NULL.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908390 13f79535-47bb-0310-9956-ffa450edef68
2023-03-14 15:43:27 +00:00
4be3a3b630 util_time: Follow up to r1908380: Avoid apr_snprintf() like others.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908389 13f79535-47bb-0310-9956-ffa450edef68
2023-03-14 15:41:42 +00:00
fffea3eb02 core: Use the main ErrorLogFormat for ap_log_perror() and while loading vhosts.
* server/core.c(create_core_server_config):
  Init sconf->error_log_format early so that it applies while the vhost
  is loading.

* server/log.c(log_error_core):
  Get the core_server_config from the main server if no server/config is
  provided.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908388 13f79535-47bb-0310-9956-ffa450edef68
2023-03-14 14:37:00 +00:00
ce1f5e6a49 util_time: Note/comments about ap_recent_ctime_ex() correctness wrt trailing \0
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908383 13f79535-47bb-0310-9956-ffa450edef68
2023-03-14 12:19:34 +00:00
e5fa6ee46e core: Add formats %{z} and %{strftime-format} to ErrorLogFormat. PR 62161.
%{z} prints the timezone offset (i.e. "[+-]nnnn") and %{strftime-format} allows
any %-format handled by [apr_]strftime().

* include/util_time.h():
  Define new AP_CTIME_OPTION_GMTOFF option for ap_recent_ctime_ex().

* server/util_time.c(ap_recent_ctime_ex):
  Handle AP_CTIME_OPTION_GMTOFF to print "[+-]nnnn" timezone.

* server/log.c(log_ctime):
  If the format contains a '%' it's for strftime(), otherwise it's builtin
  with new 'z' as AP_CTIME_OPTION_GMTOFF.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908380 13f79535-47bb-0310-9956-ffa450edef68
2023-03-14 11:11:24 +00:00
2192bd4200 fail on bad header
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1906539 13f79535-47bb-0310-9956-ffa450edef68
2023-01-10 13:18:26 +00:00
4cfcf6d610 * Log URI causing to exceed the limit to ease analysis
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1906380 13f79535-47bb-0310-9956-ffa450edef68
2023-01-04 11:36:19 +00:00
d0e92ce99c * Optimize code flow
This whole code is only needed if have a loglevel of at least DEBUG.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1906379 13f79535-47bb-0310-9956-ffa450edef68
2023-01-04 11:30:19 +00:00
48cf630810 * Use apr_size_t instead of int to harden against overflows.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1903680 13f79535-47bb-0310-9956-ffa450edef68
2022-08-25 15:57:59 +00:00
4aca2baf90 core: Follow up to r1902728: ap_max_mem_free early setting.
Set ap_max_mem_free at static initialization time so that the main thread,
created early from init_process(), has some (default) limits for its pool.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1903523 13f79535-47bb-0310-9956-ffa450edef68
2022-08-18 10:44:52 +00:00
4cc0da2152 core: Follow up to r1902728 and r1902909: Move comment where relevant.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1903522 13f79535-47bb-0310-9956-ffa450edef68
2022-08-18 10:29:05 +00:00
626fc2e079 core: Follow up to r1902728 and r1902906: simplify for APR-1.8+.
apr_threadattr_max_free_set() is now in APR-1.8.x.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902909 13f79535-47bb-0310-9956-ffa450edef68
2022-07-21 11:21:30 +00:00
39f34f5abd core: Follow up to r1902728: pools may have no allocator with APR_POOL_DEBUG.
With APR <= 1.7 and APR_POOL_DEBUG, thread's pools don't necessarily have an
allocator, so avoid apr_allocator_max_free_set(NULL) in ap_thread_create() and
ap_thread_main_create().

Also, always create an allocator in ap_thread_current_create().



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902906 13f79535-47bb-0310-9956-ffa450edef68
2022-07-21 11:05:12 +00:00
dd434a2f91 util_cpre: Follow up to r1902731: Simplify thread pool allocation.
We don't need to over-allocate pool/heap buffers and handle the (used) size,
let apr_palloc() do this exact work for us.

That way we only need an AP_THREAD_LOCAL pool with no buffer tracking, simpler.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902858 13f79535-47bb-0310-9956-ffa450edef68
2022-07-19 16:18:03 +00:00
c89c1bf394 util: Follow up to r1902728 and r1902731: static/AP_THREAD_LOCAL order matters.
gcc seems to want "static __thread"  instead of "__thread static"..



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902733 13f79535-47bb-0310-9956-ffa450edef68
2022-07-15 11:49:30 +00:00
97afea48fd util_pcre: Restore nmatch < ncaps behaviour with PCRE1 (only).
When the requested nmatch is below the number of captures for the regex (i.e.
nmatch is zero if the user does not care about the captures), with PCRE1 we can
pass a smaller ovector to pcre_exec() (or even NULL) which allows for somes
optimizations (less or even no recursion) internally in pcre.

This might avoid crashes due to stack usage/exhaustion with pathological
patterns (see BZ 66119).



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902732 13f79535-47bb-0310-9956-ffa450edef68
2022-07-15 10:46:37 +00:00
f589ecaa68 util_pcre: Add a thread local subpool cache for when stack does not suffice.
When AP_HAS_THREAD_LOCAL is available, use a thread-local match_thread_state to
save per-thread data in a subpool of the thread's pool.

If private_malloc() gets out of the stack buffer and the current thread has a
pool (i.e. ap_thread_current() != NULL), it will apr_palloc()ate and return
memory from the subpool.

When the match is complete and the match_data are freed, the thread subpool is
cleared thus giving back the memory to the allocator, which itself will give
back the memory or recycle it depending on its max_free setting.

* util_pcre.c:
  Restore POSIX_MALLOC_THRESHOLDsince this is part of the user API.

* util_pcre.c(match_data_pt):
  Type not used (explicitely) anymore, axe.
  
* util_pcre.c(struct match_data_state):
  Put the stack buffer there to simplify code (the state is allocated on
  stack anyway).
  If APREG_USE_THREAD_LOCAL, add the apr_thread_t* and match_thread_state*
  fields that track the thread local data for the match.

* util_pcre.c(alloc_match_data, free_match):
  Renamed to setup_state() and cleanup_state(), simplified (no stack buffer
  parameters anymore).
  cleanup_state() now clears the thread local subpool if used during the match.
  setup_state() set state->thd to ap_thread_current(), thus NULL if it's not a
  suitable thread for using thread local data.

* util_pcre.c(private_malloc):
  Fix a possible buf_used overflow (size <= avail < APR_ALIGN_DEFAULT(size)).
  Create the thread local subpool (once per thread) and allocate from there
  when stack space is missing and state->thd != NULL, otherwise fall back to
  malloc() still.

* util_pcre.c(private_free):
  Do nothing for thread local subpool memory, will be freed in cleanup_state
  eventually.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902731 13f79535-47bb-0310-9956-ffa450edef68
2022-07-15 10:36:24 +00:00
5382f96a3a core: Apply ap_max_mem_free to created threads' pool allocator.
Since APR does not set the threshold above which the allocator of the thread's
starts returning its memory to the system, so set ap_max_mem_free from
ap_thread_create(), ap_thread_main_create() and ap_thread_current_create().

* include/httpd.h:
  Provide our own ap_thread_create() in any case (but !APR_HAS_THREADS).
  Simplify #ifdef-ery.

* server/util.c(thread_start, ap_thread_main_create, ap_thread_current_create):
  Set ap_max_mem_free to the thread's pool allocator.
  Simplify #ifdef-ery.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902728 13f79535-47bb-0310-9956-ffa450edef68
2022-07-15 09:24:01 +00:00
5ecd716833 mpm_winnt: Follow up to r1902636: another compilation error.
Same error, elsewhere.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902641 13f79535-47bb-0310-9956-ffa450edef68
2022-07-11 00:26:12 +00:00
0f36af9db9 mpm_winnt: Fix compilation error.
server\mpm\winnt\child.c(1210,1): error C2440: 'initializing': cannot convert from 'worker_info' to 'worker_info *'



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902636 13f79535-47bb-0310-9956-ffa450edef68
2022-07-10 16:58:00 +00:00
7641312e07 Follow-up to r1902572: Remove now unused #include.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902573 13f79535-47bb-0310-9956-ffa450edef68
2022-07-08 16:24:37 +00:00
b93394ec69 Rewrite ap_regexec() without a thread-local storage context for allocations.
Provide custom malloc() and free() implementations that use a stack buffer
for first N bytes and then fall back to an ordinary malloc/free().

The key properties of this approach are:

1) Allocations with PCRE2 happen the same way as they were happening
with PCRE1 in httpd 2.4.52 and earlier.

2) There are no malloc()/free() calls for typical cases where the
match data can be kept on stack.

3) The patch avoids a malloc() for the match_data structure itself,
because the match data is allocated with the provided custom malloc()
function.

4) Using custom allocation functions should ensure that PCRE is not
going to use malloc() for any auxiliary allocations, if they are
necessary.

5) There is no per-thread state.

References:
1) https://lists.apache.org/thread/l6m7dqjkk0yy3tooyd2so0rb20jmtpwd
2) https://lists.apache.org/thread/5k9y264whn4f1ll35tvl2164dz0wphvy


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902572 13f79535-47bb-0310-9956-ffa450edef68
2022-07-08 15:07:00 +00:00
317108ee6e better error message
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902324 13f79535-47bb-0310-9956-ffa450edef68
2022-06-28 16:49:43 +00:00
8646e07534 check apr_sockaddr_info_get return value
bz #66136


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902318 13f79535-47bb-0310-9956-ffa450edef68
2022-06-28 13:06:55 +00:00
c423471891 core: log_tid support on FreeBSD.
Use pthread_getthreadid_np() when available.

BZ: 65835
Submitted by: David CARLIER <devnexen gmail.com>



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1901975 13f79535-47bb-0310-9956-ffa450edef68
2022-06-16 14:25:05 +00:00
2891153f6b mpm_prefork: Do not access the POD in ONE_PROCESS mode.
There is no POD created in ONE_PROCESS mode, so avoid crashing in child_main()
and clean_child_exit().

While at it, remove a dead code path in prefork_run() which is never reached
since the one_process path already returns/exits above.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1901974 13f79535-47bb-0310-9956-ffa450edef68
2022-06-16 13:54:39 +00:00
9878035309 fixed in 1.7 SVN but not released
just in case we reroll.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1901645 13f79535-47bb-0310-9956-ffa450edef68
2022-06-04 20:21:06 +00:00