summaryrefslogtreecommitdiffhomepage
path: root/src/http/modules/ngx_http_geo_module.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2024-03-18Fixed undefined behaviour with IPv4-mapped IPv6 addresses.Sergey Kandaurov1-2/+2
Previously, it could result when left-shifting signed integer due to implicit integer promotion, such that the most significant bit appeared on the sign bit. In practice, though, this results in the same left value as with an explicit cast, at least on known compilers, such as GCC and Clang. The reason is that in_addr_t, which is equivalent to uint32_t and same as "unsigned int" in ILP32 and LP64 data type models, has the same type width as the intermediate after integer promotion, so there's no side effects such as sign-extension. This explains why adding an explicit cast does not change object files in practice. Found with UndefinedBehaviorSanitizer (shift). Based on a patch by Piotr Sikora.
2024-03-14Geo: fixed uninitialized memory access.Piotr Sikora1-3/+1
While copying ngx_http_variable_value_t structures to geo binary base in ngx_http_geo_copy_values(), and similarly in the stream module, uninitialized parts of these structures are copied as well. These include the "escape" field and possible holes. Calculating crc32 of this data triggers uninitialized memory access. Found with MemorySanitizer. Signed-off-by: Piotr Sikora <piotr@aviatrix.com>
2022-05-30Reworked multi headers to use linked lists.Maxim Dounin1-3/+3
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.
2018-12-14Geo: fixed handling of AF_UNIX client addresses (ticket #1684).Maxim Dounin1-0/+13
Previously, AF_UNIX client addresses were handled as AF_INET, leading to unexpected results.
2018-02-21Geo: optimized configuration parser.Ruslan Ermilov1-1/+5
If the geo block parser has failed, doing more things is pointless.
2018-02-21Geo: fixed memory allocation error handling (closes #1482).Ruslan Ermilov1-11/+16
If during configuration parsing of the geo directive the memory allocation has failed, pool used to parse configuration inside the block, and sometimes the temporary pool were not destroyed.
2017-08-09Fixed calls to ngx_open_file() in certain places.Sergey Kandaurov1-1/+1
Pass NGX_FILE_OPEN to ngx_open_file() to fix "The parameter is incorrect" error on win32 when using the ssl_session_ticket_key directive or loading a binary geo base. On UNIX, this change is a no-op.
2017-08-09Style.Sergey Kandaurov1-0/+1
2016-08-25Geo: fixed indentation.Sergey Kandaurov1-5/+5
2016-08-23Geo: fixed warnings when removing nonexistent ranges.Ruslan Ermilov1-7/+3
geo $geo { ranges; 10.0.0.0-10.0.0.255 test; delete 10.0.1.0-10.0.1.255; # should warn delete 10.0.0.0-10.0.0.255; delete 10.0.0.0-10.0.0.255; # should warn }
2016-08-23Geo: fixed insertion of ranges specified in descending order.Ruslan Ermilov1-3/+8
2016-08-23Geo: fixed removing a range in certain cases.Ruslan Ermilov1-1/+1
If the range includes two or more /16 networks and does not start at the /16 boundary, the last subrange was not removed (see 91cff7f97a50 for details).
2016-08-23Geo: fixed overflow when iterating over ranges.Ruslan Ermilov1-2/+10
2016-08-18Geo: fixed access to already freed memory.Valentin Bartenev1-1/+6
Previously, in "ranges" mode when all added ranges were deleted, the ctx.high.low[i] was left pointing to a temporary array.
2014-07-08Style: add whitespace between control statement and parentheses.Piotr Sikora1-1/+1
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-08-20Backed out f1a91825730a and 7094bd12c1ff.Maxim Dounin1-1/+1
While ngx_get_full_name() might have a bit more descriptive arguments, the ngx_conf_full_name() is generally easier to use when parsing configuration and limits exposure of cycle->prefix / cycle->conf_prefix details.
2013-08-06Replaced ngx_conf_full_name() with ngx_get_full_name().Valentin Bartenev1-1/+1
The ngx_get_full_name() function takes more readable arguments list.
2013-03-21Use NGX_DEFAULT_POOL_SIZE macro where appropriate.Ruslan Ermilov1-2/+2
2013-02-27Correctly handle multiple X-Forwarded-For headers (ticket #106).Ruslan Ermilov1-6/+5
2012-12-27Geo: improved code readability.Ruslan Ermilov1-54/+61
2012-12-26Geo: made "default" affect both IPv4 and IPv6 when using prefixes.Ruslan Ermilov1-48/+77
Previously, "default" was equivalent to specifying 0.0.0.0/0, now it's equivalent to specifying both 0.0.0.0/0 and ::/0 (if support for IPv6 is enabled) with the same value.
2012-12-25Geo: properly initialize ngx_cidr_t when dealing with "default".Ruslan Ermilov1-1/+1
2012-12-25Geo: IPv6 support.Ruslan Ermilov1-79/+236
The "ranges" mode is still limited to IPv4 only.
2012-12-24Trailing whitespace fix.Ruslan Ermilov1-2/+2
2012-12-21Geo: ensure that default entry is always present.Ruslan Ermilov1-4/+2
If 0.0.0.0/32 entry was present and there was no explicit "default", we failed to add an empty string as a default value.
2012-12-21There's no need to normalize address returned by ngx_ptocidr().Ruslan Ermilov1-1/+1
2012-12-17Added checks that disallow adding a variable with an empty name.Ruslan Ermilov1-1/+8
Added variable name syntax checks to "geo" and "map" directives.
2012-12-14Geo: fixed the "ranges" without ranges case.Ruslan Ermilov1-15/+18
The following configuration returned an empty value for $geo: geo $geo { ranges; default default; }
2012-12-14Geo: improved ngx_http_geo_block() code readability.Ruslan Ermilov1-3/+2
2012-12-13Fixed variable syntax checking in "set", "geo", "limit_conn_zone",Ruslan Ermilov1-0/+7
and "perl_set" directives.
2012-08-30Fixed strict aliasing bugs when dealing with IPv4-mapped IPv6 addressesRuslan Ermilov1-1/+10
(closes #201).
2012-08-16Geo: fixed handling of ranges without default set.Maxim Dounin1-4/+4
The bug had appeared in 0.8.43 (r3653). Patch by Weibin Yao.
2012-06-08Fixed spelling of "endianness", and called it "byte ordering" in theRuslan Ermilov1-1/+1
user visible part.
2012-05-14geo: chains of trusted proxies and partial IPv6 support.Ruslan Ermilov1-74/+62
The module now supports recursive search of client address through the chain of trusted proxies, controlled by the "proxy_recursive" directive in the "geo" block. It also gets partial IPv6 support: now proxies may be specified with IPv6 addresses. Example: geo $test { ... proxy 127.0.0.1; proxy ::1; proxy_recursive; } There's also a slight change in behavior. When original client address (as specified by the "geo" directive) is one of the trusted proxies, and the value of the X-Forwarded-For request header cannot not be parsed as a valid address, an original client address will be used for lookup. Previously, 255.255.255.255 was used in this case.
2012-04-12Fixed grammar in error messages.Ruslan Ermilov1-3/+3
2012-01-18Copyright updated.Maxim Konovalov1-0/+1
2011-05-16support IPv4 mapped to IPv6 in geo moduleIgor Sysoev1-4/+28
2011-04-12use memmove() in appropriate placesIgor Sysoev1-5/+5
2010-06-30style fix: remove tabsIgor Sysoev1-10/+10
2010-06-30test binary geo range base sizeIgor Sysoev1-1/+1
2010-06-30test the second binary geo range base existenceIgor Sysoev1-0/+8
2010-06-30test binary geo ranges base only for rangesIgor Sysoev1-9/+11
2010-06-30test binary gep range base mtimeIgor Sysoev1-1/+20
2010-06-29binary geo ranges base cacheIgor Sysoev1-52/+407
2010-06-29change duplicate default geo range processingIgor Sysoev1-12/+9
2010-06-24eliminate a number of ranges: about 18,000 /16 networks are empty,Igor Sysoev1-27/+22
this change saves about 70K/140K on 32/64-bit platforms
2010-06-24break cycle earlyIgor Sysoev1-2/+2
2010-06-23style fixIgor Sysoev1-2/+2
2010-06-23change ngx_http_variable_value_node_t to more generic ngx_str_node_tIgor Sysoev1-14/+22
2010-02-25fix a geo range if the range includes two or more /16 networksIgor Sysoev1-1/+1
and does not begin at /16 network boundary