Welcome! Log In Create A New Profile

Advanced

[nginx] svn commit: r4829 - in trunk/src/http: . modules

Anonymous User
August 30, 2012 11:00AM
Author: ru
Date: 2012-08-30 14:58:11 +0000 (Thu, 30 Aug 2012)
New Revision: 4829
URL: http://trac.nginx.org/nginx/changeset/4829/nginx

Log:
Fixed strict aliasing bugs when dealing with IPv4-mapped IPv6 addresses
(closes #201).


Modified:
trunk/src/http/modules/ngx_http_geo_module.c
trunk/src/http/modules/ngx_http_geoip_module.c
trunk/src/http/ngx_http_core_module.c

Modified: trunk/src/http/modules/ngx_http_geo_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_geo_module.c 2012-08-28 13:31:01 UTC (rev 4828)
+++ trunk/src/http/modules/ngx_http_geo_module.c 2012-08-30 14:58:11 UTC (rev 4829)
@@ -233,12 +233,21 @@
#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;
}
}


Modified: trunk/src/http/modules/ngx_http_geoip_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_geoip_module.c 2012-08-28 13:31:01 UTC (rev 4828)
+++ trunk/src/http/modules/ngx_http_geoip_module.c 2012-08-30 14:58:11 UTC (rev 4829)
@@ -226,12 +226,21 @@
#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;
}
}


Modified: trunk/src/http/ngx_http_core_module.c
===================================================================
--- trunk/src/http/ngx_http_core_module.c 2012-08-28 13:31:01 UTC (rev 4828)
+++ trunk/src/http/ngx_http_core_module.c 2012-08-30 14:58:11 UTC (rev 4829)
@@ -2776,7 +2776,15 @@

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

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] svn commit: r4829 - in trunk/src/http: . modules

Anonymous User 949 August 30, 2012 11:00AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 202
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready