diff src/http/ngx_http_core_module.c @ 4857:880dedfa4008 stable-1.2

Merge of r4829: fixed strict aliasing with ipv6 (ticket #201). Fixed strict aliasing bugs when dealing with IPv4-mapped IPv6 addresses.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 24 Sep 2012 19:06:48 +0000
parents 43b7b9572fe1
children 05beaa2d87b3
line wrap: on
line diff
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -2733,7 +2733,15 @@ ngx_http_get_forwarded_addr(ngx_http_req
 
         if (IN6_IS_ADDR_V4MAPPED(inaddr6)) {
             family = AF_INET;
-            inaddr = *(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];
+
+            inaddr = htonl(inaddr);
         }
     }
 #endif