summaryrefslogtreecommitdiffhomepage
path: root/src/core/ngx_regex.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2023-10-17Core: fixed memory leak on configuration reload with PCRE2.Maxim Dounin1-3/+4
In ngx_regex_cleanup() allocator wasn't configured when calling pcre2_compile_context_free() and pcre2_match_data_free(), resulting in no ngx_free() call and leaked memory. Fix is ensure that allocator is configured for global allocations, so that ngx_free() is actually called to free memory. Additionally, ngx_regex_compile_context was cleared in ngx_regex_module_init(). It should be either not cleared, so it will be freed by ngx_regex_cleanup(), or properly freed. Fix is to not clear it, so ngx_regex_cleanup() will be able to free it. Reported by ZhenZhong Wu, https://mailman.nginx.org/pipermail/nginx-devel/2023-September/3Z5FIKUDRN2WBSL3JWTZJ7SXDA6YIWPB.html
2023-04-18Fixed segfault if regex studies list allocation fails.Maxim Dounin1-3/+3
The rcf->studies list is unconditionally accessed by ngx_regex_cleanup(), and this used to cause NULL pointer dereference if allocation failed. Fix is to set cleanup handler only when allocation succeeds.
2021-12-25Core: added NGX_REGEX_MULTILINE for 3rd party modules.Maxim Dounin1-2/+10
Notably, NAXSI is known to misuse ngx_regex_compile() with rc.options set to PCRE_CASELESS | PCRE_MULTILINE. With PCRE2 support, and notably binary compatibility changes, it is no longer possible to set PCRE[2]_MULTILINE option without using proper interface. To facilitate correct usage, this change adds the NGX_REGEX_MULTILINE option.
2021-12-25PCRE2 and PCRE binary compatibility.Maxim Dounin1-4/+42
With this change, dynamic modules using nginx regex interface can be used regardless of the variant of the PCRE library nginx was compiled with. If a module is compiled with different PCRE library variant, in case of ngx_regex_exec() errors it will report wrong function name in error messages. This is believed to be tolerable, given that fixing this will require interface changes.
2021-12-25PCRE2 library support.Maxim Dounin1-6/+325
The PCRE2 library is now used by default if found, instead of the original PCRE library. If needed for some reason, this can be disabled with the --without-pcre2 configure option. To make it possible to specify paths to the library and include files via --with-cc-opt / --with-ld-opt, the library is first tested without any additional paths and options. If this fails, the pcre2-config script is used. Similarly to the original PCRE library, it is now possible to build PCRE2 from sources with nginx configure, by using the --with-pcre= option. It automatically detects if PCRE or PCRE2 sources are provided. Note that compiling PCRE2 10.33 and later requires inttypes.h. When compiling on Windows with MSVC, inttypes.h is only available starting with MSVC 2013. In older versions some replacement needs to be provided ("echo '#include <stdint.h>' > pcre2-10.xx/src/inttypes.h" is good enough for MSVC 2010). The interface on nginx side remains unchanged.
2021-12-25Core: ngx_regex.c style cleanup.Maxim Dounin1-17/+17
Notably, ngx_pcre_pool and ngx_pcre_studies are renamed to ngx_regex_pool and ngx_regex_studies, respectively.
2021-12-25Core: fixed ngx_pcre_studies cleanup.Maxim Dounin1-40/+43
If a configuration parsing fails for some reason, ngx_regex_module_init() is not called, and ngx_pcre_studies remained set despite the fact that the pool it was allocated from is already freed. This might result in a segmentation fault during runtime regular expression compilation, such as in SSI, for example, in the single process mode, or if a worker process died and was respawned from a master process in such an inconsistent state. Fix is to clear ngx_pcre_studies from the pool cleanup handler (which is anyway used to free JIT-compiled patterns).
2017-08-10Style.Maxim Dounin1-2/+2
2016-04-12Fixed NGX_CONF_TAKE1/NGX_CONF_FLAG misuse (as in e444e8f6538b).Ruslan Ermilov1-1/+1
2015-03-26Removed ngx_threaded and related code.Ruslan Ermilov1-37/+0
2015-03-04Renamed NGX_THREADS to NGX_OLD_THREADS because of deprecation.Ruslan Ermilov1-3/+3
It's mostly dead code and the original idea of worker threads has been rejected.
2014-09-08Core: ngx_regex_compile() error handling fixes.Maxim Dounin1-3/+11
Now we actually return NGX_ERROR on errors, and provide an error string for memory allocation errors. Reported by Markus Linnala.
2012-05-17Fixed the ngx_regex.h header file compatibility with C++.Valentin Bartenev1-3/+3
2012-01-30Fixed memory leak on HUP signal when PCRE JIT was used.Valentin Bartenev1-1/+54
The PCRE JIT compiler uses mmap to allocate memory for its executable codes, so we have to explicitly call the pcre_free_study() function to free this memory.
2012-01-24Fixed grammar in PCRE JIT error log message.Valentin Bartenev1-1/+1
2012-01-18Copyright updated.Maxim Konovalov1-0/+1
2011-12-26Added support for regex study and PCRE JIT (ticket #41) optimizations onValentin Bartenev1-5/+210
configuration phase.
2011-12-06Removed unused function ngx_regex_capture_count().Valentin Bartenev1-17/+0
The function has been unused since r3326.
2009-11-17fix pcre allocation on Win32, the bug had been introduced in r3326Igor Sysoev1-6/+2
2009-11-16regex named capturesIgor Sysoev1-31/+94
2009-11-13ngx_regex_exec() calling optimiztion:Igor Sysoev1-16/+0
*) change NGX_REGEX_NO_MATCHED to PCRE_ERROR_NOMATCH *) declare ngx_regex_exec() as #define *) optimize SSI regex a little
2008-06-17*) back out r2040Igor Sysoev1-1/+1
*) refactor ngx_palloc() *) introduce ngx_pnalloc() *) additional pool blocks have smaller header
2008-05-27*) add ngx_palloc_aligned() to allocate explicitlty aligned memoryIgor Sysoev1-1/+1
*) allows non-aligned memory blocks for small allocations and for odd length strings on all platforms *) use ngx_palloc_aligned()
2007-12-27ngx_regex_exec_array()Igor Sysoev1-0/+33
2005-03-22nginx-0.1.26-RELEASE importrelease-0.1.26Igor Sysoev1-10/+15
*) Change: the invalid client header lines are now ignored and logged at the info level. *) Change: the server name is also logged in error log. *) Feature: the ngx_http_auth_basic_module module and the auth_basic and auth_basic_user_file directives.
2005-03-19nginx-0.1.25-RELEASE importrelease-0.1.25Igor Sysoev1-2/+6
*) Bugfix: nginx did run on Linux parisc. *) Feature: nginx now does not start under FreeBSD if the sysctl kern.ipc.somaxconn value is too big. *) Bugfix: if a request was internally redirected by the ngx_http_index_module module to the ngx_http_proxy_module or ngx_http_fastcgi_module modules, then the index file was not closed after request completion. *) Feature: the "proxy_pass" can be used in location with regular expression. *) Feature: the ngx_http_rewrite_filter_module module supports the condition like "if ($HTTP_USER_AGENT ~ MSIE)". *) Bugfix: nginx started too slow if the large number of addresses and text values were used in the "geo" directive. *) Change: a variable name must be declared as "$name" in the "geo" directive. The previous variant without "$" is still supported, but will be removed soon. *) Feature: the "%{VARIABLE}v" logging parameter. *) Feature: the "set $name value" directive. *) Bugfix: gcc 4.0 compatibility. *) Feature: the --with-openssl-opt=OPTIONS autoconfiguration directive.
2005-03-04nginx-0.1.24-RELEASE importrelease-0.1.24Igor Sysoev1-1/+1
*) Feature: the ngx_http_ssi_filter_module supports the QUERY_STRING and DOCUMENT_URI variables. *) Bugfix: the ngx_http_autoindex_module may some times return the 404 response for existent directory, if this directory was used in "alias" directive. *) Bugfix: the ngx_http_ssi_filter_module ran incorrectly for large responses. *) Bugfix: the lack of the "Referer" header line was always accounted as valid referrer.
2005-01-19nginx-0.1.15-RELEASE importrelease-0.1.15Igor Sysoev1-3/+15
*) Bugfix: the error while the connecting to the FastCGI server caused segmentation fault. *) Bugfix: the correct handling of the regular expression, that has different number of the captures and substitutions. *) Feature: the location, that is passed to the FastCGI server, can be regular expression. *) Bugfix: the FastCGI's parameter REQUEST_URI is now passed with the arguments and in the original state. *) Bugfix: the ngx_http_rewrite_module module was required to be built to use the regular expressions in locations. *) Bugfix: the directive "proxy_preserve_host on" adds port 80 to the "Host" headers, if upstream listen on port 80; the bug had appeared in 0.1.14. *) Bugfix: the same paths in autoconfiguration parameters --http-client-body-temp-path=PATH and --http-proxy-temp-path=PATH, or --http-client-body-temp-path=PATH and --http-fastcgi-temp-path=PATH caused segmentation fault.
2005-01-18nginx-0.1.14-RELEASE importrelease-0.1.14Igor Sysoev1-2/+2
*) Feature: the autoconfiguration directives: --http-client-body-temp-path=PATH, --http-proxy-temp-path=PATH, and --http-fastcgi-temp-path=PATH *) Change: the directory name for the temporary files with the client request body is specified by directive client_body_temp_path, by default it is <prefix>/client_body_temp. *) Feature: the ngx_http_fastcgi_module and the directives: fastcgi_pass, fastcgi_root, fastcgi_index, fastcgi_params, fastcgi_connect_timeout, fastcgi_send_timeout, fastcgi_read_timeout, fastcgi_send_lowat, fastcgi_header_buffer_size, fastcgi_buffers, fastcgi_busy_buffers_size, fastcgi_temp_path, fastcgi_max_temp_file_size, fastcgi_temp_file_write_size, fastcgi_next_upstream, and fastcgi_x_powered_by. *) Bugfix: the "[alert] zero size buf" error; the bug had appeared in 0.1.3. *) Change: the URI must be specified after the host name in the proxy_pass directive. *) Change: the %3F symbol in the URI was considered as the argument string start. *) Feature: the unix domain sockets support in the ngx_http_proxy_module. *) Feature: the ssl_engine and ssl_ciphers directives. Thanks to Sergey Skvortsov for SSL-accelerator.
2004-11-11nginx-0.1.5-RELEASE importrelease-0.1.5Igor Sysoev1-2/+2
*) Bugfix: on Solaris and Linux there may be too many "recvmsg() returned not enough data" alerts. *) Bugfix: there were the "writev() failed (22: Invalid argument)" errors on Solaris in proxy mode without sendfile. On other platforms that do not support sendfile at all the process got caught in an endless loop. *) Bugfix: segmentation fault on Solaris in proxy mode and using sendfile. *) Bugfix: segmentation fault on Solaris. *) Bugfix: on-line upgrade did not work on Linux. *) Bugfix: the ngx_http_autoindex_module module did not escape the spaces, the quotes, and the percent signs in the directory listing. *) Change: the decrease of the copy operations. *) Feature: the userid_p3p directive.
2004-09-29nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyrightIgor Sysoev1-1/+1
2004-09-28nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused filesIgor Sysoev1-0/+5
2004-07-07nginx-0.0.7-2004-07-07-19:01:00 importIgor Sysoev1-6/+44
2004-03-23nginx-0.0.3-2004-03-23-09:01:52 importIgor Sysoev1-1/+9
2004-03-16nginx-0.0.2-2004-03-16-10:10:12 importIgor Sysoev1-4/+6
2003-12-25nginx-0.0.1-2003-12-25-23:26:58 importIgor Sysoev1-2/+3
2003-12-08nginx-0.0.1-2003-12-08-23:48:12 importIgor Sysoev1-1/+1
2003-11-25nginx-0.0.1-2003-11-25-23:44:56 importIgor Sysoev1-0/+71