[nginx] Fixed port ranges support in the listen directive.

Sergey Kandaurov pluknet at nginx.com
Fri Dec 23 15:25:32 UTC 2022


details:   https://hg.nginx.org/nginx/rev/2af1287d2da7
branches:  
changeset: 8117:2af1287d2da7
user:      Valentin Bartenev <vbart at wbsrv.ru>
date:      Sun Dec 18 21:29:02 2022 +0300
description:
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).

diffstat:

 src/http/ngx_http_core_module.c     |  2 +-
 src/mail/ngx_mail_core_module.c     |  2 +-
 src/stream/ngx_stream_core_module.c |  2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r 3108d4d668e4 -r 2af1287d2da7 src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c	Fri Dec 16 01:15:15 2022 +0400
+++ b/src/http/ngx_http_core_module.c	Sun Dec 18 21:29:02 2022 +0300
@@ -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 -r 3108d4d668e4 -r 2af1287d2da7 src/mail/ngx_mail_core_module.c
--- a/src/mail/ngx_mail_core_module.c	Fri Dec 16 01:15:15 2022 +0400
+++ b/src/mail/ngx_mail_core_module.c	Sun Dec 18 21:29:02 2022 +0300
@@ -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 -r 3108d4d668e4 -r 2af1287d2da7 src/stream/ngx_stream_core_module.c
--- a/src/stream/ngx_stream_core_module.c	Fri Dec 16 01:15:15 2022 +0400
+++ b/src/stream/ngx_stream_core_module.c	Sun Dec 18 21:29:02 2022 +0300
@@ -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