summaryrefslogtreecommitdiffhomepage
path: root/src/http/modules/ngx_http_geo_module.c
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@nginx.com>2012-08-30 14:58:11 +0000
committerRuslan Ermilov <ru@nginx.com>2012-08-30 14:58:11 +0000
commitd469482cda460107c034f8d9e723de830a1f768e (patch)
tree5ab93300c30e9f5f37ee136831f5bc961cca848c /src/http/modules/ngx_http_geo_module.c
parentda4ffd8955b14383d6c027004d8beb85395ce9f5 (diff)
downloadnginx-d469482cda460107c034f8d9e723de830a1f768e.tar.gz
nginx-d469482cda460107c034f8d9e723de830a1f768e.tar.bz2
Fixed strict aliasing bugs when dealing with IPv4-mapped IPv6 addresses
(closes #201).
Diffstat (limited to 'src/http/modules/ngx_http_geo_module.c')
-rw-r--r--src/http/modules/ngx_http_geo_module.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/http/modules/ngx_http_geo_module.c b/src/http/modules/ngx_http_geo_module.c
index 230816247..fce87a8cb 100644
--- a/src/http/modules/ngx_http_geo_module.c
+++ b/src/http/modules/ngx_http_geo_module.c
@@ -233,12 +233,21 @@ ngx_http_geo_addr(ngx_http_request_t *r, ngx_http_geo_ctx_t *ctx)
#if (NGX_HAVE_INET6)
if (addr.sockaddr->sa_family == AF_INET6) {
+ u_char *p;
+ in_addr_t inaddr;
struct in6_addr *inaddr6;
inaddr6 = &((struct sockaddr_in6 *) addr.sockaddr)->sin6_addr;
if (IN6_IS_ADDR_V4MAPPED(inaddr6)) {
- return ntohl(*(in_addr_t *) &inaddr6->s6_addr[12]);
+ p = inaddr6->s6_addr;
+
+ inaddr = p[12] << 24;
+ inaddr += p[13] << 16;
+ inaddr += p[14] << 8;
+ inaddr += p[15];
+
+ return inaddr;
}
}