aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_variables.c
Commit message (Collapse)AuthorAge
* Variables: avoid possible buffer overrun with some "$sent_http_*".Sergey Kandaurov2023-05-01
| | | | | | | | | | | | | | | The existing logic to evaluate multi header "$sent_http_*" variables, such as $sent_http_cache_control, as previously introduced in 1.23.0, doesn't take into account that one or more elements can be cleared, yet still present in a linked list, pointed to by the next field. Such elements don't contribute to the resulting variable length, an attempt to append a separator for them ends up in out of bounds write. This is not possible with standard modules, though at least one third party module is known to override multi header values this way, so it makes sense to harden the logic. The fix restores a generic boundary check.
* PROXY protocol v2 TLV variables.Roman Arutyunyan2022-10-12
| | | | | The variables have prefix $proxy_protocol_tlv_ and are accessible by name and by type. Examples are: $proxy_protocol_tlv_0x01, $proxy_protocol_tlv_alpn.
* All non-unique input headers are now linked lists.Maxim Dounin2022-05-30
| | | | | | The ngx_http_process_multi_header_lines() function is removed, as it is exactly equivalent to ngx_http_process_header_line(). Similarly, ngx_http_variable_header() is used instead of ngx_http_variable_headers().
* Reworked multi headers to use linked lists.Maxim Dounin2022-05-30
| | | | | | | | | | | | | | | | | Multi headers are now using linked lists instead of arrays. Notably, the following fields were changed: r->headers_in.cookies (renamed to r->headers_in.cookie), r->headers_in.x_forwarded_for, r->headers_out.cache_control, r->headers_out.link, u->headers_in.cache_control u->headers_in.cookies (renamed to u->headers_in.set_cookie). The r->headers_in.cookies and u->headers_in.cookies fields were renamed to r->headers_in.cookie and u->headers_in.set_cookie to match header names. The ngx_http_parse_multi_header_lines() and ngx_http_parse_set_cookie_lines() functions were changed accordingly. With this change, multi headers are now essentially equivalent to normal headers, and following changes will further make them equivalent.
* Combining unknown headers during variables lookup (ticket #1316).Maxim Dounin2022-05-30
| | | | | | | | | | | | | | | | Previously, $http_*, $sent_http_*, $sent_trailer_*, $upstream_http_*, and $upstream_trailer_* variables returned only the first header (with a few specially handled exceptions: $http_cookie, $http_x_forwarded_for, $sent_http_cache_control, $sent_http_link). With this change, all headers are returned, combined together. For example, $http_foo variable will be "a, b" if there are "Foo: a" and "Foo: b" headers in the request. Note that $upstream_http_set_cookie will also return all "Set-Cookie" headers (ticket #1843), though this might not be what one want, since the "Set-Cookie" header does not follow the list syntax (see RFC 7230, section 3.2.2).
* Fixed $content_length cacheability with chunked (ticket #2252).Maxim Dounin2021-10-06
|
* Added $connection_time variable.Maxim Dounin2021-04-08
|
* Variables: fixed buffer over-read when evaluating "$arg_".Sergey Kandaurov2020-05-08
|
* Parsing server PROXY protocol address and port (ticket #1206).Roman Arutyunyan2019-10-21
| | | | | New variables $proxy_protocol_server_addr and $proxy_protocol_server_port are added both to HTTP and Stream.
* Core: moved PROXY protocol fields out of ngx_connection_t.Roman Arutyunyan2019-10-21
| | | | | | Now a new structure ngx_proxy_protocol_t holds these fields. This allows to add more PROXY protocol fields in the future without modifying the connection structure.
* Variables support in limit_rate and limit_rate_after (ticket #293).Ruslan Ermilov2019-04-24
|
* Copy regex unnamed captures to cloned subrequests.Roman Arutyunyan2018-12-11
| | | | | | | | | | | | Previously, unnamed regex captures matched in the parent request, were not available in a cloned subrequest. Now 3 fields related to unnamed captures are copied to a cloned subrequest: r->ncaptures, r->captures and r->captures_data. Since r->captures cannot be changed by either request after creating a clone, a new flag r->realloc_captures is introduced to force reallocation of r->captures. The issue was reported as a proxy_cache_background_update misbehavior in http://mailman.nginx.org/pipermail/nginx/2018-December/057251.html.
* Improved code readablity.Ruslan Ermilov2018-03-07
| | | | No functional changes.
* Basic support of the Link response header.Ruslan Ermilov2018-02-08
|
* Fixed handling of unix sockets in $binary_remote_addr.Maxim Dounin2017-10-04
| | | | | | | | | | | | | | Previously, unix sockets were treated as AF_INET ones, and this may result in buffer overread on Linux, where unbound unix sockets have 2-byte addresses. Note that it is not correct to use just sun_path as a binary representation for unix sockets. This will result in an empty string for unbound unix sockets, and thus behaviour of limit_req and limit_conn will change when switching from $remote_addr to $binary_remote_addr. As such, normal text representation is used. Reported by Stephan Dollberg.
* Variables: macros for null variables.Ruslan Ermilov2017-08-01
| | | | No functional changes.
* Variables: use ngx_http_variable_null_value where appropriate.Ruslan Ermilov2017-07-07
|
* Added support for trailers in HTTP responses.Piotr Sikora2017-03-24
| | | | | | | | | | | | | | | | | | | | | | | | | Example: ngx_table_elt_t *h; h = ngx_list_push(&r->headers_out.trailers); if (h == NULL) { return NGX_ERROR; } ngx_str_set(&h->key, "Fun"); ngx_str_set(&h->value, "with trailers"); h->hash = ngx_hash_key_lc(h->key.data, h->key.len); The code above adds "Fun: with trailers" trailer to the response. Modules that want to emit trailers must set r->expect_trailers = 1 in header filter, otherwise they might not be emitted for HTTP/1.1 responses that aren't already chunked. This change also adds $sent_trailer_* variables. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
* Variables: generic prefix variables.Dmitry Volyntsev2017-01-31
|
* Limited recursion when evaluating variables.Ruslan Ermilov2016-12-21
| | | | Unlimited recursion might cause stack exhaustion in some misconfigurations.
* Introduced ngx_inet_get_port() and ngx_inet_set_port() functions.Roman Arutyunyan2016-06-20
|
* Added the $proxy_protocol_port variable.Dmitry Volyntsev2016-05-23
|
* Variable $request_id.Vladimir Homutov2016-04-26
| | | | | The variable contains text representation based on random data, usable as a unique request identifier.
* Fixed logging with variable field width.Sergey Kandaurov2016-03-31
|
* Fixed variables prefix comparison.Maxim Dounin2015-10-19
| | | | | | | | Variable names are not null-terminated, so using ngx_strncmp() without extra length checks is wrong. Reported by Markus Linnala, http://mailman.nginx.org/pipermail/nginx-devel/2015-August/007211.html.
* Request body: unbuffered reading.Maxim Dounin2015-03-23
| | | | | | | | | | | The r->request_body_no_buffering flag was introduced. It instructs client request body reading code to avoid reading the whole body, and to call post_handler early instead. The caller should use the ngx_http_read_unbuffered_request_body() function to read remaining parts of the body. Upstream module is now able to use this mode, if configured with the proxy_request_buffering directive.
* Variables: fixed non-indexed access of prefix vars (ticket #600).Maxim Dounin2014-08-27
| | | | | | | | | | | | | | | | Previously, a configuration like location / { ssi on; ssi_types *; set $http_foo "bar"; return 200 '<!--#echo var="http_foo" -->\n'; } resulted in NULL pointer dereference in ngx_http_get_variable() as the variable was explicitly added to the variables hash, but its get_handler wasn't properly set in the hash. Fix is to make sure that get_handler is properly set by ngx_http_variables_init_vars().
* Setting $args now invalidates unparsed uri.Maxim Dounin2014-05-19
| | | | Prodded by Yichun Zhang.
* Upstream: added the "$upstream_cookie_<name>" variables.Vladimir Homutov2014-04-29
|
* Added server-side support for PROXY protocol v1 (ticket #355).Roman Arutyunyan2014-03-17
| | | | | | | | Client address specified in the PROXY protocol header is now saved in the $proxy_protocol_addr variable and can be used in the realip module. This is currently not implemented for mail.
* Fixed handling of UNIX-domain sockets.Ruslan Ermilov2013-12-09
| | | | | When evaluating $local_port, $server_port, and $server_addr, UNIX-domain sockets were mistakenly interpreted as IPv4 sockets.
* Removed extra allocation for $sent_http_last_modified.Maxim Dounin2013-10-31
| | | | | There is no need to allocate memory for "Last-Modified: " string, the variable only contains date itself.
* Win32: $request_time fixed.Maxim Dounin2013-09-04
| | | | | | On win32, time_t is 64 bits wide by default, and passing an ngx_msec_int_t argument for %T format specifier doesn't work. This doesn't manifest itself on other platforms as time_t and ngx_msec_int_t are usually of the same size.
* Format specifier fixes in error logging.Sergey Kandaurov2013-08-20
|
* Fixed memory leaks in the root and auth_basic_user_file directives.Valentin Bartenev2013-08-06
| | | | | | | | If a relative path is set by variables, then the ngx_conf_full_name() function was called while processing requests, which causes allocations from the cycle pool. A new function that takes pool as an argument was introduced.
* PCRE: retain input pattern for all regular expressions.Piotr Sikora2013-05-02
| | | | | | | | | Previously, input pattern was kept only for regular expressions with named captures, which resulted in error log entries without input pattern for PCRE errors that occured while processing regular expressions without them. Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
* Correctly handle multiple X-Forwarded-For headers (ticket #106).Ruslan Ermilov2013-02-27
|
* Fixed separator in $sent_http_cache_control.Ruslan Ermilov2013-02-27
| | | | | | In case multiple "Cache-Control" headers are sent to a client, multiple values in $sent_http_cache_control were incorrectly split by a semicolon. Now they are split by a comma.
* Proxy: support for connection upgrade (101 Switching Protocols).Maxim Dounin2013-02-18
| | | | | | | | | | | | | | This allows to proxy WebSockets by using configuration like this: location /chat/ { proxy_pass http://backend; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } Connection upgrade is allowed as long as it was requested by a client via the Upgrade request header.
* Variables $pipe, $request_length, $time_iso8601, and $time_local.Ruslan Ermilov2013-01-21
| | | | | | Log module counterparts are preserved for efficiency. Based on patch by Kiril Kalchev.
* Added checks that disallow adding a variable with an empty name.Ruslan Ermilov2012-12-17
| | | | Added variable name syntax checks to "geo" and "map" directives.
* Request body: $content_length variable to honor real body size.Maxim Dounin2012-11-21
| | | | | This allows to handle requests with chunked body by fastcgi and uwsgi modules, and also simplifies handling of various request body modifications.
* Request body: $request_body variable generalization.Maxim Dounin2012-11-21
| | | | | | | The $request_body variable was assuming there can't be more than two buffers. While this is currently true due to request body reading implementation details, this is not a good thing to depend on and may change in the future.
* Variables $request_time and $msec.Ruslan Ermilov2012-11-16
| | | | Log module counterparts are preserved for efficiency.
* Variables $connection and $connection_requests.Maxim Dounin2012-10-29
| | | | | Log module counterparts are removed as they aren't used often and there is no need to preserve them for efficiency.
* Variable $bytes_sent.Maxim Dounin2012-10-03
| | | | | | | It replicates variable $bytes_sent as previously available in log module only. Patch by Benjamin Grössing (with minor changes).
* Fixed compile-time conditionals used to detect if X-Forwarded-For supportRuslan Ermilov2012-06-21
| | | | is needed.
* Style fix.Andrey Belov2012-06-18
|
* New core variable: $status.Andrey Belov2012-06-18
| | | | | | | | Contains response status code as a 3-digit integer (with leading zeroes if necessary), or one of the following values: 000 - response status code has not yet been assigned 009 - HTTP/0.9 request is being processed
* Fixed core variables dynamic access after reconfiguration.Maxim Dounin2012-05-17
| | | | | | | | If variable was indexed in previous configuration but not in current one, the NGX_HTTP_VAR_INDEXED flag was left set and confused ngx_http_get_variable(). Patch by Yichun Zhang (agentzh), slightly modified.