[PATCH] Fixed port ranges support in the listen directive
Valentin V. Bartenev
vbart at wbsrv.ru
Sun Dec 18 18:36:55 UTC 2022
# HG changeset patch
# User Valentin Bartenev <vbart at wbsrv.ru>
# Date 1671388142 -10800
# Sun Dec 18 21:29:02 2022 +0300
# Node ID 2af1287d2da744335932f6dca345618f7b80d1c1
# Parent 3108d4d668e4b907868b815f0441d4c893bf4188
Fixed port ranges support in the listen directive.
Ports difference must be respected when checking addresses for duplicates,
otherwise configurations like this are broken:
listen 127.0.0.1:6000-6005
It was broken by 4cc2bfeff46c (nginx 1.23.3).
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -4292,7 +4292,7 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx
for (i = 0; i < n; i++) {
if (ngx_cmp_sockaddr(u.addrs[n].sockaddr, u.addrs[n].socklen,
- u.addrs[i].sockaddr, u.addrs[i].socklen, 0)
+ u.addrs[i].sockaddr, u.addrs[i].socklen, 1)
== NGX_OK)
{
goto next;
diff --git a/src/mail/ngx_mail_core_module.c b/src/mail/ngx_mail_core_module.c
--- a/src/mail/ngx_mail_core_module.c
+++ b/src/mail/ngx_mail_core_module.c
@@ -572,7 +572,7 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx
for (i = 0; i < n; i++) {
if (ngx_cmp_sockaddr(u.addrs[n].sockaddr, u.addrs[n].socklen,
- u.addrs[i].sockaddr, u.addrs[i].socklen, 0)
+ u.addrs[i].sockaddr, u.addrs[i].socklen, 1)
== NGX_OK)
{
goto next;
diff --git a/src/stream/ngx_stream_core_module.c b/src/stream/ngx_stream_core_module.c
--- a/src/stream/ngx_stream_core_module.c
+++ b/src/stream/ngx_stream_core_module.c
@@ -890,7 +890,7 @@ ngx_stream_core_listen(ngx_conf_t *cf, n
for (i = 0; i < n; i++) {
if (ngx_cmp_sockaddr(u.addrs[n].sockaddr, u.addrs[n].socklen,
- u.addrs[i].sockaddr, u.addrs[i].socklen, 0)
+ u.addrs[i].sockaddr, u.addrs[i].socklen, 1)
== NGX_OK)
{
goto next;
More information about the nginx-devel
mailing list