Mercurial > hg > nginx
comparison src/http/modules/ngx_http_geoip_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 | a05e7b09af5a |
children | 7ce4ecb6df5c |
comparison
equal
deleted
inserted
replaced
4856:43b7b9572fe1 | 4857:880dedfa4008 |
---|---|
224 } | 224 } |
225 | 225 |
226 #if (NGX_HAVE_INET6) | 226 #if (NGX_HAVE_INET6) |
227 | 227 |
228 if (addr.sockaddr->sa_family == AF_INET6) { | 228 if (addr.sockaddr->sa_family == AF_INET6) { |
229 u_char *p; | |
230 in_addr_t inaddr; | |
229 struct in6_addr *inaddr6; | 231 struct in6_addr *inaddr6; |
230 | 232 |
231 inaddr6 = &((struct sockaddr_in6 *) addr.sockaddr)->sin6_addr; | 233 inaddr6 = &((struct sockaddr_in6 *) addr.sockaddr)->sin6_addr; |
232 | 234 |
233 if (IN6_IS_ADDR_V4MAPPED(inaddr6)) { | 235 if (IN6_IS_ADDR_V4MAPPED(inaddr6)) { |
234 return ntohl(*(in_addr_t *) &inaddr6->s6_addr[12]); | 236 p = inaddr6->s6_addr; |
237 | |
238 inaddr = p[12] << 24; | |
239 inaddr += p[13] << 16; | |
240 inaddr += p[14] << 8; | |
241 inaddr += p[15]; | |
242 | |
243 return inaddr; | |
235 } | 244 } |
236 } | 245 } |
237 | 246 |
238 #endif | 247 #endif |
239 | 248 |