Welcome! Log In Create A New Profile

Advanced

[nginx] Geo: fixed handling of AF_UNIX client addresses (ticket #1684).

Maxim Dounin
December 14, 2018 11:54AM
details: https://hg.nginx.org/nginx/rev/286ae954009d
branches:
changeset: 7430:286ae954009d
user: Maxim Dounin <mdounin@mdounin.ru>
date: Fri Dec 14 18:11:06 2018 +0300
description:
Geo: fixed handling of AF_UNIX client addresses (ticket #1684).

Previously, AF_UNIX client addresses were handled as AF_INET, leading
to unexpected results.

diffstat:

src/http/modules/ngx_http_geo_module.c | 13 +++++++++++++
src/stream/ngx_stream_geo_module.c | 13 +++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)

diffs (60 lines):

diff --git a/src/http/modules/ngx_http_geo_module.c b/src/http/modules/ngx_http_geo_module.c
--- a/src/http/modules/ngx_http_geo_module.c
+++ b/src/http/modules/ngx_http_geo_module.c
@@ -215,6 +215,13 @@ ngx_http_geo_cidr_variable(ngx_http_requ
break;
#endif

+#if (NGX_HAVE_UNIX_DOMAIN)
+ case AF_UNIX:
+ vv = (ngx_http_variable_value_t *)
+ ngx_radix32tree_find(ctx->u.trees.tree, INADDR_NONE);
+ break;
+#endif
+
default: /* AF_INET */
sin = (struct sockaddr_in *) addr.sockaddr;
inaddr = ntohl(sin->sin_addr.s_addr);
@@ -277,6 +284,12 @@ ngx_http_geo_range_variable(ngx_http_req
break;
#endif

+#if (NGX_HAVE_UNIX_DOMAIN)
+ case AF_UNIX:
+ inaddr = INADDR_NONE;
+ break;
+#endif
+
default: /* AF_INET */
sin = (struct sockaddr_in *) addr.sockaddr;
inaddr = ntohl(sin->sin_addr.s_addr);
diff --git a/src/stream/ngx_stream_geo_module.c b/src/stream/ngx_stream_geo_module.c
--- a/src/stream/ngx_stream_geo_module.c
+++ b/src/stream/ngx_stream_geo_module.c
@@ -206,6 +206,13 @@ ngx_stream_geo_cidr_variable(ngx_stream_
break;
#endif

+#if (NGX_HAVE_UNIX_DOMAIN)
+ case AF_UNIX:
+ vv = (ngx_stream_variable_value_t *)
+ ngx_radix32tree_find(ctx->u.trees.tree, INADDR_NONE);
+ break;
+#endif
+
default: /* AF_INET */
sin = (struct sockaddr_in *) addr.sockaddr;
inaddr = ntohl(sin->sin_addr.s_addr);
@@ -268,6 +275,12 @@ ngx_stream_geo_range_variable(ngx_stream
break;
#endif

+#if (NGX_HAVE_UNIX_DOMAIN)
+ case AF_UNIX:
+ inaddr = INADDR_NONE;
+ break;
+#endif
+
default: /* AF_INET */
sin = (struct sockaddr_in *) addr.sockaddr;
inaddr = ntohl(sin->sin_addr.s_addr);
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Geo: fixed handling of AF_UNIX client addresses (ticket #1684).

Maxim Dounin 137 December 14, 2018 11:54AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 82
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready