List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:January 19 2012 1:15am
Subject:bzr push into mysql-trunk-wl5259 branch (chris.powers:3354)
View as plain text  
 3354 Christopher Powers	2012-01-18 [merge]
      local merge

    added:
      mysql-test/include/have_ipv6.inc
      mysql-test/suite/sys_vars/r/host_cache_size_basic.result
      mysql-test/suite/sys_vars/t/host_cache_size_basic-master.opt
      mysql-test/suite/sys_vars/t/host_cache_size_basic.test
    modified:
      mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_deny.test
      mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_deny.test
      mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_allow.test
      mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_deny.test
      mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_deny.test
      mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_deny.test
      mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_deny.test
      sql/sys_vars.cc
=== modified file 'sql/hostname.cc'
--- a/sql/hostname.cc	2012-01-17 13:48:50 +0000
+++ b/sql/hostname.cc	2012-01-19 01:06:19 +0000
@@ -618,35 +618,49 @@ bool ip_to_hostname(struct sockaddr_stor
                     if (free_addr_info_list)
                       freeaddrinfo(addr_info_list);
 
-                    struct sockaddr_in *debug_addr;
+                    addr_info_list= NULL;
+                    free_addr_info_list= false;
+                    err_code= 0;
+
                     /*
                       Not thread safe, which is ok.
                       Only one connection at a time is tested with
                       fault injection.
                     */
-                    static struct sockaddr_in debug_sock_addr[2];
+                    static struct sockaddr_in saddr1;
+                    static struct sockaddr_in saddr2;
                     static struct addrinfo debug_addr_info[2];
-                    /* Simulating ipv4 192.0.2.126 */
-                    debug_addr= & debug_sock_addr[0];
-                    debug_addr->sin_family= AF_INET;
-                    inet_pton(AF_INET, "192.0.2.126", & debug_addr->sin_addr);
-
-                    /* Simulating ipv4 192.0.2.127 */
-                    debug_addr= & debug_sock_addr[1];
-                    debug_addr->sin_family= AF_INET;
-                    inet_pton(AF_INET, "192.0.2.127", & debug_addr->sin_addr);
-
-                    debug_addr_info[0].ai_addr= (struct sockaddr*) & debug_sock_addr[0];
-                    debug_addr_info[0].ai_addrlen= sizeof (struct sockaddr_in);
-                    debug_addr_info[0].ai_next= & debug_addr_info[1];
-
-                    debug_addr_info[1].ai_addr= (struct sockaddr*) & debug_sock_addr[1];
-                    debug_addr_info[1].ai_addrlen= sizeof (struct sockaddr_in);
-                    debug_addr_info[1].ai_next= NULL;
+                    static struct addrinfo hints;
+                    static struct addrinfo *ainfo= NULL;
 
-                    addr_info_list= & debug_addr_info[0];
-                    err_code= 0;
-                    free_addr_info_list= false;
+                    hints.ai_flags= AI_NUMERICHOST;
+                    hints.ai_family= AF_INET;
+
+                    /*
+                      Simulating ipv4 192.0.2.126
+                      WinXP does not support inet_pton(), so use getaddrinfo().
+                    */
+                    err_code= getaddrinfo("192.0.2.126", NULL, &hints, &ainfo);
+                    if (err_code == 0)
+                    {
+                      memcpy(&saddr1, ainfo->ai_addr, ainfo->ai_addrlen);
+                      debug_addr_info[0].ai_addr= (struct sockaddr*)&saddr1;
+                      debug_addr_info[0].ai_addrlen= sizeof (struct sockaddr_in);
+                      debug_addr_info[0].ai_next= &debug_addr_info[1];
+                      freeaddrinfo(ainfo);
+
+                      /* Simulating ipv4 192.0.2.127 */
+                      err_code= getaddrinfo("192.0.2.127", NULL, &hints, &ainfo);
+                      if (err_code == 0)
+                      {
+                        memcpy(&saddr2, ainfo->ai_addr, ainfo->ai_addrlen);
+                        debug_addr_info[1].ai_addr= (struct sockaddr*)&saddr2;
+                        debug_addr_info[1].ai_addrlen= ainfo->ai_addrlen;
+                        debug_addr_info[1].ai_next= NULL;
+                        addr_info_list= &debug_addr_info[0];
+                        freeaddrinfo(ainfo);
+                      }
+                    }
                   }
                   );
 
@@ -655,30 +669,41 @@ bool ip_to_hostname(struct sockaddr_stor
                     if (free_addr_info_list)
                       freeaddrinfo(addr_info_list);
 
-                    struct sockaddr_in *debug_addr;
-                    static struct sockaddr_in debug_sock_addr[2];
+                    addr_info_list= NULL;
+                    free_addr_info_list= false;
+                    err_code= 0;
+
+                    static struct sockaddr_in saddr1;
+                    static struct sockaddr_in saddr2;
                     static struct addrinfo debug_addr_info[2];
-                    /* Simulating ipv4 192.0.2.5 */
-                    debug_addr= & debug_sock_addr[0];
-                    debug_addr->sin_family= AF_INET;
-                    inet_pton(AF_INET, "192.0.2.5", & debug_addr->sin_addr);
-
-                    /* Simulating ipv4 192.0.2.4 */
-                    debug_addr= & debug_sock_addr[1];
-                    debug_addr->sin_family= AF_INET;
-                    inet_pton(AF_INET, "192.0.2.4", & debug_addr->sin_addr);
-
-                    debug_addr_info[0].ai_addr= (struct sockaddr*) & debug_sock_addr[0];
-                    debug_addr_info[0].ai_addrlen= sizeof (struct sockaddr_in);
-                    debug_addr_info[0].ai_next= & debug_addr_info[1];
-
-                    debug_addr_info[1].ai_addr= (struct sockaddr*) & debug_sock_addr[1];
-                    debug_addr_info[1].ai_addrlen= sizeof (struct sockaddr_in);
-                    debug_addr_info[1].ai_next= NULL;
+                    static struct addrinfo hints;
+                    static struct addrinfo *ainfo= NULL;
 
-                    addr_info_list= & debug_addr_info[0];
-                    err_code= 0;
-                    free_addr_info_list= false;
+                    hints.ai_flags= AI_NUMERICHOST;
+                    hints.ai_family= AF_INET;
+
+                    /* Simulating ipv4 192.0.2.5 */
+                    err_code= getaddrinfo("192.0.2.5", NULL, &hints, &ainfo);
+                    if (err_code == 0)
+                    {
+                      memcpy(&saddr1, ainfo->ai_addr, ainfo->ai_addrlen);
+                      debug_addr_info[0].ai_addr= (struct sockaddr*)&saddr1;
+                      debug_addr_info[0].ai_addrlen= ainfo->ai_addrlen;
+                      debug_addr_info[0].ai_next= &debug_addr_info[1];
+                      freeaddrinfo(ainfo);
+
+                      /* Simulating ipv4 192.0.2.4 */
+                      err_code= getaddrinfo("192.0.2.4", NULL, &hints, &ainfo);
+                      if (err_code == 0)
+                      {
+                        memcpy(&saddr2, ainfo->ai_addr, ainfo->ai_addrlen);
+                        debug_addr_info[1].ai_addr= (struct sockaddr*)&saddr2;
+                        debug_addr_info[1].ai_addrlen= sizeof (struct sockaddr_in);
+                        debug_addr_info[1].ai_next= NULL;
+                        addr_info_list= &debug_addr_info[0];
+                        freeaddrinfo(ainfo);
+                      }
+                    }
                   }
                   );
 
@@ -688,73 +713,93 @@ bool ip_to_hostname(struct sockaddr_stor
                     if (free_addr_info_list)
                       freeaddrinfo(addr_info_list);
 
-                    struct sockaddr_in6 *debug_addr;
+                    addr_info_list= NULL;
+                    free_addr_info_list= false;
+                    err_code= 0;
+
                     /*
                       Not thread safe, which is ok.
                       Only one connection at a time is tested with
                       fault injection.
                     */
-                    static struct sockaddr_in6 debug_sock_addr[2];
+                    static struct sockaddr_in6 saddr1;
+                    static struct sockaddr_in6 saddr2;
                     static struct addrinfo debug_addr_info[2];
-                    /* Simulating ipv6 2001:DB8::6:7E */
-                    debug_addr= & debug_sock_addr[0];
-                    debug_addr->sin6_family= AF_INET6;
-                    inet_pton(AF_INET6, "2001:DB8::6:7E", & debug_addr->sin6_addr);
-
-                    /* Simulating ipv6 2001:DB8::6:7F */
-                    debug_addr= & debug_sock_addr[1];
-                    debug_addr->sin6_family= AF_INET6;
-                    inet_pton(AF_INET6, "2001:DB8::6:7F", & debug_addr->sin6_addr);
-
-                    debug_addr_info[0].ai_addr= (struct sockaddr*) & debug_sock_addr[0];
-                    debug_addr_info[0].ai_addrlen= sizeof (struct sockaddr_in6);
-                    debug_addr_info[0].ai_next= & debug_addr_info[1];
-
-                    debug_addr_info[1].ai_addr= (struct sockaddr*) & debug_sock_addr[1];
-                    debug_addr_info[1].ai_addrlen= sizeof (struct sockaddr_in6);
-                    debug_addr_info[1].ai_next= NULL;
+                    static struct addrinfo hints;
+                    static struct addrinfo *ainfo= NULL;
 
-                    addr_info_list= & debug_addr_info[0];
-                    err_code= 0;
-                    free_addr_info_list= false;
+                    hints.ai_flags= AI_NUMERICHOST;
+                    hints.ai_family= AF_INET6;
+
+                    /*
+                      Simulating ipv6 2001:DB8::6:7E
+                      WinXP does not support inet_pton(), so use getaddrinfo().
+                    */
+                    err_code= getaddrinfo("2001:DB8::6:7E", NULL, &hints, &ainfo);
+                    if (err_code == 0)
+                    {
+                      memcpy(&saddr1, ainfo->ai_addr, ainfo->ai_addrlen);
+                      debug_addr_info[0].ai_addr= (struct sockaddr*)&saddr1;
+                      debug_addr_info[0].ai_addrlen= ainfo->ai_addrlen;
+                      debug_addr_info[0].ai_next= &debug_addr_info[1];
+                      freeaddrinfo(ainfo);
+
+                      /* Simulating ipv6 2001:DB8::6:7F */
+                      err_code= getaddrinfo("2001:DB8::6:7F", NULL, &hints, &ainfo);
+                      if (err_code == 0)
+                      {
+                        memcpy(&saddr2, ainfo->ai_addr, ainfo->ai_addrlen);
+                        debug_addr_info[1].ai_addr= (struct sockaddr*)&saddr2;
+                        debug_addr_info[1].ai_addrlen= ainfo->ai_addrlen;
+                        debug_addr_info[1].ai_next= NULL;
+                        addr_info_list= &debug_addr_info[0];
+                        freeaddrinfo(ainfo);
+                      }
+                    }
                   }
-                  );
+                );
 
   DBUG_EXECUTE_IF("getaddrinfo_fake_good_ipv6",
                   {
                     if (free_addr_info_list)
                       freeaddrinfo(addr_info_list);
 
-                    struct sockaddr_in6 *debug_addr;
-                    /*
-                      Not thread safe, which is ok.
-                      Only one connection at a time is tested with
-                      fault injection.
-                    */
-                    static struct sockaddr_in6 debug_sock_addr[2];
+                    addr_info_list= NULL;
+                    free_addr_info_list= false;
+                    err_code= 0;
+
+                    static struct sockaddr_in6 saddr1;
+                    static struct sockaddr_in6 saddr2;
                     static struct addrinfo debug_addr_info[2];
-                    /* Simulating ipv6 2001:DB8::6:7 */
-                    debug_addr= & debug_sock_addr[0];
-                    debug_addr->sin6_family= AF_INET6;
-                    inet_pton(AF_INET6, "2001:DB8::6:7", & debug_addr->sin6_addr);
-
-                    /* Simulating ipv6 2001:DB8::6:6 */
-                    debug_addr= & debug_sock_addr[1];
-                    debug_addr->sin6_family= AF_INET6;
-                    inet_pton(AF_INET6, "2001:DB8::6:6", & debug_addr->sin6_addr);
-
-                    debug_addr_info[0].ai_addr= (struct sockaddr*) & debug_sock_addr[0];
-                    debug_addr_info[0].ai_addrlen= sizeof (struct sockaddr_in6);
-                    debug_addr_info[0].ai_next= & debug_addr_info[1];
-
-                    debug_addr_info[1].ai_addr= (struct sockaddr*) & debug_sock_addr[1];
-                    debug_addr_info[1].ai_addrlen= sizeof (struct sockaddr_in6);
-                    debug_addr_info[1].ai_next= NULL;
+                    static struct addrinfo hints;
+                    static struct addrinfo *ainfo= NULL;
 
-                    addr_info_list= & debug_addr_info[0];
-                    err_code= 0;
-                    free_addr_info_list= false;
-                  }
+                    hints.ai_flags= AI_NUMERICHOST;
+                    hints.ai_family= AF_INET6;
+
+                    /* Simulating ipv6 2001:DB8::6:7 */
+                    err_code= getaddrinfo("2001:DB8::6:7", NULL, &hints, &ainfo);
+                    if (err_code == 0)
+                    {
+                      memcpy(&saddr1, ainfo->ai_addr, ainfo->ai_addrlen);
+                      debug_addr_info[0].ai_addr= (struct sockaddr*)&saddr1;
+                      debug_addr_info[0].ai_addrlen= ainfo->ai_addrlen;
+                      debug_addr_info[0].ai_next= &debug_addr_info[1];
+                      freeaddrinfo(ainfo);
+
+                      /* Simulating ipv6 2001:DB8::6:6 */
+                      err_code= getaddrinfo("2001:DB8::6:6", NULL, &hints, &ainfo);
+                      if (err_code == 0)
+                      {
+                        memcpy(&saddr2, ainfo->ai_addr, ainfo->ai_addrlen);
+                        debug_addr_info[1].ai_addr= (struct sockaddr*)&saddr2;
+                        debug_addr_info[1].ai_addrlen= ainfo->ai_addrlen;
+                        debug_addr_info[1].ai_next= NULL;
+                        addr_info_list= &debug_addr_info[0];
+                        freeaddrinfo(ainfo);
+                      }
+                    }
+                    }
                   );
 #endif /* HAVE_IPV6 */
 

=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc	2012-01-17 08:31:24 +0000
+++ b/sql/sql_connect.cc	2012-01-19 01:06:19 +0000
@@ -480,11 +480,20 @@ static int check_connection(THD *thd)
                       struct sockaddr *sa= (sockaddr *) &net->vio->remote;
                       sa->sa_family= AF_INET;
                       struct in_addr *ip4= &((struct sockaddr_in *) sa)->sin_addr;
+                      static struct addrinfo hints;
+                      static struct addrinfo *ainfo= NULL;
+                      hints.ai_flags= AI_NUMERICHOST;
+                      hints.ai_family= AF_INET;
                       /* See RFC 5737, 192.0.2.0/24 is reserved. */
                       const char* fake= "192.0.2.4";
-                      inet_pton(AF_INET, fake, ip4);
                       strcpy(ip, fake);
-                      peer_rc= 0;
+                      /* WinXP does not support inet_pton(), so use getaddrinfo(). */
+                      peer_rc= (my_bool)getaddrinfo(fake, NULL, &hints, &ainfo);
+                      if (peer_rc == 0)
+                      {
+                        *ip4= ((sockaddr_in*)(ainfo->ai_addr))->sin_addr;
+                        freeaddrinfo(ainfo);
+                      }
                     }
                     );
 
@@ -494,11 +503,20 @@ static int check_connection(THD *thd)
                       struct sockaddr_in6 *sa= (sockaddr_in6 *) &net->vio->remote;
                       sa->sin6_family= AF_INET6;
                       struct in6_addr *ip6= & sa->sin6_addr;
+                      static struct addrinfo hints;
+                      static struct addrinfo *ainfo= NULL;
+                      hints.ai_flags= AI_NUMERICHOST;
+                      hints.ai_family= AF_INET6;
                       /* See RFC 3849, ipv6 2001:DB8::/32 is reserved. */
                       const char* fake= "2001:db8::6:6";
-                      inet_pton(AF_INET6, fake, ip6);
                       strcpy(ip, fake);
-                      peer_rc= 0;
+                      /* WinXP does not support inet_pton(), so use getaddrinfo(). */
+                      peer_rc= (my_bool)getaddrinfo(fake, NULL, &hints, &ainfo);
+                      if (peer_rc == 0)
+                      {
+                        *ip6= ((sockaddr_in6*)(ainfo->ai_addr))->sin6_addr;
+                        freeaddrinfo(ainfo);
+                      }
                     }
                     );
 #endif /* HAVE_IPV6 */

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl5259 branch (chris.powers:3354) Christopher Powers20 Jan