summaryrefslogtreecommitdiff
path: root/server
Commit message (Collapse)AuthorAgeFilesLines
* Fix a possible null pointer dereference in ap_expr_parse()Giovanni Bechis2023-03-281-1/+4
| | | | | | | | | | | | | | | | | 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
* check apreq_cookie_make return valueGiovanni Bechis2023-03-231-0/+4
| | | | | | | Github: closes #302 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908673 13f79535-47bb-0310-9956-ffa450edef68
* util_time: Follow up to r1908380 and r1908389: apr_strings.h not needed anymore.Yann Ylavic2023-03-201-1/+0
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908556 13f79535-47bb-0310-9956-ffa450edef68
* core: Follow up to r1908393: comment about where ap_server_conf is set.Yann Ylavic2023-03-151-2/+2
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908406 13f79535-47bb-0310-9956-ffa450edef68
* core: Follow up to r1908393: ap_server_conf to NULL before ap_read_config().Yann Ylavic2023-03-141-0/+2
| | | | | | | | Just to be sure.. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908394 13f79535-47bb-0310-9956-ffa450edef68
* core: Set ap_server_conf ASAP.Yann Ylavic2023-03-142-4/+7
| | | | | | | | | | | | | * 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
* log: Follow up to r1908388: ap_server_conf might be NULL.Yann Ylavic2023-03-141-3/+5
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908390 13f79535-47bb-0310-9956-ffa450edef68
* util_time: Follow up to r1908380: Avoid apr_snprintf() like others.Yann Ylavic2023-03-141-6/+10
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908389 13f79535-47bb-0310-9956-ffa450edef68
* core: Use the main ErrorLogFormat for ap_log_perror() and while loading vhosts.Yann Ylavic2023-03-142-1/+13
| | | | | | | | | | | | | | * 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
* util_time: Note/comments about ap_recent_ctime_ex() correctness wrt trailing \0Yann Ylavic2023-03-141-2/+4
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908383 13f79535-47bb-0310-9956-ffa450edef68
* core: Add formats %{z} and %{strftime-format} to ErrorLogFormat. PR 62161.Yann Ylavic2023-03-142-10/+48
| | | | | | | | | | | | | | | | | | | %{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
* fail on bad headerEric Covener2023-01-101-0/+2
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1906539 13f79535-47bb-0310-9956-ffa450edef68
* * Log URI causing to exceed the limit to ease analysisRuediger Pluem2023-01-041-4/+10
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1906380 13f79535-47bb-0310-9956-ffa450edef68
* * Optimize code flowRuediger Pluem2023-01-041-17/+19
| | | | | | | 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
* * Use apr_size_t instead of int to harden against overflows.Ruediger Pluem2022-08-251-2/+2
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1903680 13f79535-47bb-0310-9956-ffa450edef68
* core: Follow up to r1902728: ap_max_mem_free early setting.Yann Ylavic2022-08-181-1/+1
| | | | | | | | | 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
* core: Follow up to r1902728 and r1902909: Move comment where relevant.Yann Ylavic2022-08-181-1/+1
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1903522 13f79535-47bb-0310-9956-ffa450edef68
* core: Follow up to r1902728 and r1902906: simplify for APR-1.8+.Yann Ylavic2022-07-211-15/+2
| | | | | | | | 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
* core: Follow up to r1902728: pools may have no allocator with APR_POOL_DEBUG.Yann Ylavic2022-07-211-12/+31
| | | | | | | | | | | | 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
* util_cpre: Follow up to r1902731: Simplify thread pool allocation.Yann Ylavic2022-07-191-64/+21
| | | | | | | | | | | 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
* util: Follow up to r1902728 and r1902731: static/AP_THREAD_LOCAL order matters.Yann Ylavic2022-07-152-2/+2
| | | | | | | | 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
* util_pcre: Restore nmatch < ncaps behaviour with PCRE1 (only).Yann Ylavic2022-07-151-0/+26
| | | | | | | | | | | | | | 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
* util_pcre: Add a thread local subpool cache for when stack does not suffice.Yann Ylavic2022-07-151-61/+164
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* core: Apply ap_max_mem_free to created threads' pool allocator.Yann Ylavic2022-07-151-53/+62
| | | | | | | | | | | | | | | | | | 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
* mpm_winnt: Follow up to r1902636: another compilation error.Yann Ylavic2022-07-111-1/+1
| | | | | | | | Same error, elsewhere. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902641 13f79535-47bb-0310-9956-ffa450edef68
* mpm_winnt: Fix compilation error.Yann Ylavic2022-07-101-1/+1
| | | | | | | | 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
* Follow-up to r1902572: Remove now unused #include.Ivan Zhakov2022-07-081-1/+0
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902573 13f79535-47bb-0310-9956-ffa450edef68
* Rewrite ap_regexec() without a thread-local storage context for allocations.Ivan Zhakov2022-07-081-101/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* better error messageGiovanni Bechis2022-06-281-1/+2
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902324 13f79535-47bb-0310-9956-ffa450edef68
* check apr_sockaddr_info_get return valueGiovanni Bechis2022-06-281-1/+6
| | | | | | | bz #66136 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1902318 13f79535-47bb-0310-9956-ffa450edef68
* core: log_tid support on FreeBSD.Yann Ylavic2022-06-161-2/+8
| | | | | | | | | | | 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
* mpm_prefork: Do not access the POD in ONE_PROCESS mode.Yann Ylavic2022-06-161-8/+6
| | | | | | | | | | | | 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
* fixed in 1.7 SVN but not releasedEric Covener2022-06-041-1/+1
| | | | | | | | just in case we reroll. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1901645 13f79535-47bb-0310-9956-ffa450edef68
* force to 0 on 1.6 on WindowsEric Covener2022-06-041-0/+6
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1901619 13f79535-47bb-0310-9956-ffa450edef68
* handle large writes in ap_rputsEric Covener2022-06-011-0/+3
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1901500 13f79535-47bb-0310-9956-ffa450edef68
* use a liberal default limit for LimitRequestBody of 1GBEric Covener2022-06-011-1/+1
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1901497 13f79535-47bb-0310-9956-ffa450edef68
* fix typesEric Covener2022-06-011-2/+2
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1901494 13f79535-47bb-0310-9956-ffa450edef68
* * Avoid an overflow on large inputsRuediger Pluem2022-04-271-4/+2
| | | | | | | PR: 66033 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1900306 13f79535-47bb-0310-9956-ffa450edef68
* core: Disable TCP_NOPUSH optimization on OSX. BZ 66019.Yann Ylavic2022-04-211-5/+17
| | | | | | | | | | | | | | | | | | OSX supports TCP_NOPUSH but does not release the data retained (in TCP stack) when the option is unset. It seems that unsetting it before the last write does not help either so just disable the optimization for OSX in the core output filter to avoid uncontrollable transmission delays. * server/core_filters.c(): Add the sock_nopush() helper that does nothing on OSX and platforms not supporting TCP_NOPUSH or TCP_CORK. * server/core_filters.c(send_brigade_nonblocking): Use sock_nopush() instead of apr_socket_opt_set() for APR_TCP_NOPUSH option. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1900100 13f79535-47bb-0310-9956-ffa450edef68
* *) core: add ap_sb_get_child_thread() to retrieve child_numStefan Eissing2022-04-191-0/+8
| | | | | | | | and thread_num from a scoreboard handle. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1900029 13f79535-47bb-0310-9956-ffa450edef68
* *) de-duplicate ALOGNO from code copy.Stefan Eissing2022-04-191-1/+1
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1900024 13f79535-47bb-0310-9956-ffa450edef68
* *) core: improved checks in ap_escape_quotes() forStefan Eissing2022-04-161-2/+19
| | | | | | | | | | extra long strings (or resulting strings) that exceed ptrdiff_t ranges. [Yann Ylavic, Stefan Eissing] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899905 13f79535-47bb-0310-9956-ffa450edef68
* * Port r1899858, r1899865 to worker MPMRuediger Pluem2022-04-151-3/+23
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899884 13f79535-47bb-0310-9956-ffa450edef68
* mpm_event: Follow up to r1899858: Avoid explicit sleep.Yann Ylavic2022-04-141-12/+11
| | | | | | | | | | Instead, we can simply go to ap_wait_or_timeout() again. While at it, improve the comment about killed processes. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899865 13f79535-47bb-0310-9956-ffa450edef68
* mpm_event: Handle children killed pathologically.Yann Ylavic2022-04-141-3/+24
| | | | | | | | | | | | | If children processes get killed (SIGSEGV/SIGABRT/..) early after starting or frequently enough then we never enter perform_idle_server_maintenance() to try something. Below three successive children killed restart them immediately, above three let's sleep the usual 1s (to avoid fork()s flood) and do the idle maintenance. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899858 13f79535-47bb-0310-9956-ffa450edef68
* mpm_event: Follow up to r1899777: Fix max_daemon_used.Yann Ylavic2022-04-131-9/+7
| | | | git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899812 13f79535-47bb-0310-9956-ffa450edef68
* Merge PR 311:Stefan Eissing2022-04-131-418/+257
| | | | | | | | | | | | | | | | *) core/mod_http: use REQUEST meta buckets and a new HTTP/1.x specific input filter to separate the handling for HTTP requests from the handling of HTTP/1.x request parsing and checks. A new HTTP1_REQUEST_IN filter installs itself on http/1.1 connections before a request is being read. It generates either a REQUEST meta bucket on success or an ERROR bucket with the proposed response status. The core connection processing, relying on ap_read_request(), now expects a REQUEST or ERROR bucket from the input filters and is agnostic to specific HTTP versions and how they bring requests into the server. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899799 13f79535-47bb-0310-9956-ffa450edef68
* Remove libsystemd dependency from main httpd binaryJoe Orton2022-04-121-36/+26
| | | | | | | | | | | | | | | Until this change httpd was linking libsystemd to the main httpd binary. If you want to run lightweight version of httpd in container, sometimes you just want to install httpd binary with as little dependencies as possible to make container small in size and do not pull uncencessary dependencies and libraries. This change will move all systemd library calls from listen.c to mod_systemd module and remove systemd linking from the main httpd bin. Fixed mixed declaration and wrongly declared variable. Submitted by: Luboš Uhliarik <luhliari redhat.com> Github: closes #312 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899784 13f79535-47bb-0310-9956-ffa450edef68
* mpm_event: Fix accounting of active/total processes on ungraceful restart.Yann Ylavic2022-04-121-52/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Children processes terminated by ap_{reclaim,relieve}_child_processes() were were not un-accounted for total_daemons and active_daemons, which was done in server_main_loop() only. This led to perform_idle_server_maintenance() thinking it was over the limit of children processes and never create new ones. Have this accounting right in event_note_child_{started,stopped}() which is called both at runtime and reload time. * server/mpm/event/event.c(struct event_retained_data): Rename field max_daemons_limit to max_daemon_used to better describe what it's about and to align with AP_MPMQ_MAX_DAEMON_USED. * server/mpm/event/event.c(event_note_child_stopped): Renamed from event_note_child_killed() to clarify that it's not only called when a child is killed (i.e. on restart) but whenever a child has stopped. * server/mpm/event/event.c(event_note_child_stopped): Move decrementing {active,total}_daemons and marking child's threads as SERVER_DEAD from server_main_loop() so that it's done both at runtime and reload time. Log the current number/state of daemons at APLOG_DEBUG level for each child stopped. * server/mpm/event/event.c(event_note_child_started): Move incrementing {active,total}_daemons from make_child() for symmetry, given that make_child() calls event_note_child_started(). Log the current number/state of daemons at APLOG_DEBUG level for each child started. * server/mpm/event/event.c(perform_idle_server_maintenance): Fix possible miscounting of retained->max_daemon_used accross the multiple calls to perform_idle_server_maintenance() if ListenCoresBucketsRatio > 0. Pass an int *max_daemon_used which starts at zero and is bumped consistently for all the buckets, while retained->max_daemon_used is updated only after all the buckets have been maintained. * server/mpm/event/event.c(perform_idle_server_maintenance): Use event_note_child_stopped() to handle exited children processes. Fixes: BZ 66004 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899777 13f79535-47bb-0310-9956-ffa450edef68
* *) core/mod_http: use RESPONSE meta buckets and a new HTTP/1.x specificStefan Eissing2022-04-071-39/+19
| | | | | | | | | | | | | | filter to send responses through the output filter chain. Specifically: the HTTP_HEADER output filter and ap_send_interim_response() create a RESPONSE bucket and no longer are concerned with HTTP/1.x serialization. A new HTTP1_RESPONSE_OUT transcode filter writes the proper HTTP/1.x bytes when dealing with a RESPONSE bucket. That filter installs itself on the pre_read_request hook when the connection has protocol 'http/1.1'. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899648 13f79535-47bb-0310-9956-ffa450edef68