]> git.kaiwu.me - nginx.git/commitdiff
Geo: fixed removing a range in certain cases.
authorRuslan Ermilov <ru@nginx.com>
Tue, 23 Aug 2016 12:59:06 +0000 (15:59 +0300)
committerRuslan Ermilov <ru@nginx.com>
Tue, 23 Aug 2016 12:59:06 +0000 (15:59 +0300)
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).

src/http/modules/ngx_http_geo_module.c
src/stream/ngx_stream_geo_module.c

index af061af81d58aeae5505239688b4492398552165..e64380401f55dacd05b16767cff14c59fd8849d2 100644 (file)
@@ -966,7 +966,7 @@ ngx_http_geo_delete_range(ngx_conf_t *cf, ngx_http_geo_conf_ctx_t *ctx,
 
     warn = 0;
 
-    for (n = start; n <= end; n += 0x10000) {
+    for (n = start; n <= end; n = (n + 0x10000) & 0xffff0000) {
 
         h = n >> 16;
 
index 3bdeff723d61788d18825cf158cf8434121801c4..1ee0154d385fad41eddd01f0ac4bc4885d168ad3 100644 (file)
@@ -916,7 +916,7 @@ ngx_stream_geo_delete_range(ngx_conf_t *cf, ngx_stream_geo_conf_ctx_t *ctx,
 
     warn = 0;
 
-    for (n = start; n <= end; n += 0x10000) {
+    for (n = start; n <= end; n = (n + 0x10000) & 0xffff0000) {
 
         h = n >> 16;