aboutsummaryrefslogtreecommitdiff
path: root/src/core/ngx_inet.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-06-24 16:07:04 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-06-24 16:07:04 +0000
commit59f3aa3a9baeab8c8277332e75a83f134d1e026a (patch)
treeb9f4b4b2b84ec0fb29b12a901b5704abbfe5eb06 /src/core/ngx_inet.c
parentc83f683553cb76dcc9b7311495383edbacccf06d (diff)
downloadnginx-59f3aa3a9baeab8c8277332e75a83f134d1e026a.tar.gz
nginx-59f3aa3a9baeab8c8277332e75a83f134d1e026a.zip
nginx-0.0.7-2004-06-24-20:07:04 import
Diffstat (limited to 'src/core/ngx_inet.c')
-rw-r--r--src/core/ngx_inet.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/core/ngx_inet.c b/src/core/ngx_inet.c
index 5c032a2d0..68be0ef02 100644
--- a/src/core/ngx_inet.c
+++ b/src/core/ngx_inet.c
@@ -170,6 +170,7 @@ size_t ngx_inet_ntop(int family, void *addr, u_char *text, size_t len)
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 @@ ngx_int_t ngx_ptocidr(ngx_str_t *text, void *cidr)
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;
}