nginx-0.0.7-2004-06-24-20:07:04 import
diff --git a/src/core/ngx_inet.c b/src/core/ngx_inet.c
index 5c032a2..68be0ef 100644
--- a/src/core/ngx_inet.c
+++ b/src/core/ngx_inet.c
@@ -170,6 +170,7 @@
ngx_int_t ngx_ptocidr(ngx_str_t *text, void *cidr)
{
+ ngx_int_t m;
ngx_uint_t i;
ngx_inet_cidr_t *in_cidr;
@@ -192,10 +193,20 @@
return NGX_ERROR;
}
- in_cidr->mask = ngx_atoi(&text->data[i + 1], text->len - (i + 1));
- if (in_cidr->mask == (in_addr_t) NGX_ERROR) {
+ m = ngx_atoi(&text->data[i + 1], text->len - (i + 1));
+ if (m == NGX_ERROR) {
return NGX_ERROR;
}
+ if (m == 0) {
+
+ /* the x86 compilers use the shl instruction that shifts by modulo 32 */
+
+ in_cidr->mask = 0;
+ return NGX_OK;
+ }
+
+ in_cidr->mask = (ngx_uint_t) (0 - (1 << (32 - m)));
+
return NGX_OK;
}