Skip to content

Commit 6be439d

Browse files
committed
Fixed windows XP build breaks
1 parent 28c1d36 commit 6be439d

File tree

2 files changed

+109
-22
lines changed

2 files changed

+109
-22
lines changed

sql/hostname.cc

+80-18
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,13 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
446446
err_code= vio_getnameinfo(ip, hostname_buffer, NI_MAXHOST, NULL, 0,
447447
NI_NAMEREQD);
448448

449+
/*
450+
===========================================================================
451+
DEBUG code only (begin)
452+
Simulate various output from vio_getnameinfo().
453+
===========================================================================
454+
*/
455+
449456
DBUG_EXECUTE_IF("getnameinfo_error_noname",
450457
{
451458
strcpy(hostname_buffer, "<garbage>");
@@ -488,6 +495,12 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
488495
}
489496
);
490497

498+
/*
499+
===========================================================================
500+
DEBUG code only (end)
501+
===========================================================================
502+
*/
503+
491504
if (err_code)
492505
{
493506
// NOTE: gai_strerror() returns a string ending by a dot.
@@ -588,7 +601,8 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
588601

589602
/*
590603
===========================================================================
591-
DBUG CODE (begin)
604+
DEBUG code only (begin)
605+
Simulate various output from getaddrinfo().
592606
===========================================================================
593607
*/
594608
DBUG_EXECUTE_IF("getaddrinfo_error_noname",
@@ -702,19 +716,43 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
702716
debug_addr->sin6_family= AF_INET6;
703717
ip6= & debug_addr->sin6_addr;
704718
/* inet_pton not available on Windows XP. */
705-
ip6->s6_addr32[0] = htonl(0x20010db8);
706-
ip6->s6_addr32[1] = htonl(0x00000000);
707-
ip6->s6_addr32[2] = htonl(0x00000000);
708-
ip6->s6_addr32[3] = htonl(0x0006007e);
719+
ip6->s6_addr[ 0] = 0x20;
720+
ip6->s6_addr[ 1] = 0x01;
721+
ip6->s6_addr[ 2] = 0x0d;
722+
ip6->s6_addr[ 3] = 0xb8;
723+
ip6->s6_addr[ 4] = 0x00;
724+
ip6->s6_addr[ 5] = 0x00;
725+
ip6->s6_addr[ 6] = 0x00;
726+
ip6->s6_addr[ 7] = 0x00;
727+
ip6->s6_addr[ 8] = 0x00;
728+
ip6->s6_addr[ 9] = 0x00;
729+
ip6->s6_addr[10] = 0x00;
730+
ip6->s6_addr[11] = 0x00;
731+
ip6->s6_addr[12] = 0x00;
732+
ip6->s6_addr[13] = 0x06;
733+
ip6->s6_addr[14] = 0x00;
734+
ip6->s6_addr[15] = 0x7e;
709735

710736
/* Simulating ipv6 2001:DB8::6:7F */
711737
debug_addr= & debug_sock_addr[1];
712738
debug_addr->sin6_family= AF_INET6;
713739
ip6= & debug_addr->sin6_addr;
714-
ip6->s6_addr32[0] = htonl(0x20010db8);
715-
ip6->s6_addr32[1] = htonl(0x00000000);
716-
ip6->s6_addr32[2] = htonl(0x00000000);
717-
ip6->s6_addr32[3] = htonl(0x0006007f);
740+
ip6->s6_addr[ 0] = 0x20;
741+
ip6->s6_addr[ 1] = 0x01;
742+
ip6->s6_addr[ 2] = 0x0d;
743+
ip6->s6_addr[ 3] = 0xb8;
744+
ip6->s6_addr[ 4] = 0x00;
745+
ip6->s6_addr[ 5] = 0x00;
746+
ip6->s6_addr[ 6] = 0x00;
747+
ip6->s6_addr[ 7] = 0x00;
748+
ip6->s6_addr[ 8] = 0x00;
749+
ip6->s6_addr[ 9] = 0x00;
750+
ip6->s6_addr[10] = 0x00;
751+
ip6->s6_addr[11] = 0x00;
752+
ip6->s6_addr[12] = 0x00;
753+
ip6->s6_addr[13] = 0x06;
754+
ip6->s6_addr[14] = 0x00;
755+
ip6->s6_addr[15] = 0x7f;
718756

719757
debug_addr_info[0].ai_addr= (struct sockaddr*) & debug_sock_addr[0];
720758
debug_addr_info[0].ai_addrlen= sizeof (struct sockaddr_in6);
@@ -748,19 +786,43 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
748786
debug_addr= & debug_sock_addr[0];
749787
debug_addr->sin6_family= AF_INET6;
750788
ip6= & debug_addr->sin6_addr;
751-
ip6->s6_addr32[0] = htonl(0x20010db8);
752-
ip6->s6_addr32[1] = htonl(0x00000000);
753-
ip6->s6_addr32[2] = htonl(0x00000000);
754-
ip6->s6_addr32[3] = htonl(0x00060007);
789+
ip6->s6_addr[ 0] = 0x20;
790+
ip6->s6_addr[ 1] = 0x01;
791+
ip6->s6_addr[ 2] = 0x0d;
792+
ip6->s6_addr[ 3] = 0xb8;
793+
ip6->s6_addr[ 4] = 0x00;
794+
ip6->s6_addr[ 5] = 0x00;
795+
ip6->s6_addr[ 6] = 0x00;
796+
ip6->s6_addr[ 7] = 0x00;
797+
ip6->s6_addr[ 8] = 0x00;
798+
ip6->s6_addr[ 9] = 0x00;
799+
ip6->s6_addr[10] = 0x00;
800+
ip6->s6_addr[11] = 0x00;
801+
ip6->s6_addr[12] = 0x00;
802+
ip6->s6_addr[13] = 0x06;
803+
ip6->s6_addr[14] = 0x00;
804+
ip6->s6_addr[15] = 0x07;
755805

756806
/* Simulating ipv6 2001:DB8::6:6 */
757807
debug_addr= & debug_sock_addr[1];
758808
debug_addr->sin6_family= AF_INET6;
759809
ip6= & debug_addr->sin6_addr;
760-
ip6->s6_addr32[0] = htonl(0x20010db8);
761-
ip6->s6_addr32[1] = htonl(0x00000000);
762-
ip6->s6_addr32[2] = htonl(0x00000000);
763-
ip6->s6_addr32[3] = htonl(0x00060006);
810+
ip6->s6_addr[ 0] = 0x20;
811+
ip6->s6_addr[ 1] = 0x01;
812+
ip6->s6_addr[ 2] = 0x0d;
813+
ip6->s6_addr[ 3] = 0xb8;
814+
ip6->s6_addr[ 4] = 0x00;
815+
ip6->s6_addr[ 5] = 0x00;
816+
ip6->s6_addr[ 6] = 0x00;
817+
ip6->s6_addr[ 7] = 0x00;
818+
ip6->s6_addr[ 8] = 0x00;
819+
ip6->s6_addr[ 9] = 0x00;
820+
ip6->s6_addr[10] = 0x00;
821+
ip6->s6_addr[11] = 0x00;
822+
ip6->s6_addr[12] = 0x00;
823+
ip6->s6_addr[13] = 0x06;
824+
ip6->s6_addr[14] = 0x00;
825+
ip6->s6_addr[15] = 0x06;
764826

765827
debug_addr_info[0].ai_addr= (struct sockaddr*) & debug_sock_addr[0];
766828
debug_addr_info[0].ai_addrlen= sizeof (struct sockaddr_in6);
@@ -779,7 +841,7 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
779841

780842
/*
781843
===========================================================================
782-
DBUG CODE (end)
844+
DEBUG code only (end)
783845
===========================================================================
784846
*/
785847

sql/sql_connect.cc

+29-4
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,13 @@ static int check_connection(THD *thd)
470470

471471
peer_rc= vio_peer_addr(net->vio, ip, &thd->peer_port, NI_MAXHOST);
472472

473+
/*
474+
===========================================================================
475+
DEBUG code only (begin)
476+
Simulate various output from vio_peer_addr().
477+
===========================================================================
478+
*/
479+
473480
DBUG_EXECUTE_IF("vio_peer_addr_error",
474481
{
475482
peer_rc= 1;
@@ -497,16 +504,34 @@ static int check_connection(THD *thd)
497504
/* See RFC 3849, ipv6 2001:DB8::/32 is reserved. */
498505
const char* fake= "2001:db8::6:6";
499506
/* inet_pton(AF_INET6, fake, ip6); not available on Windows XP. */
500-
ip6->s6_addr32[0] = htonl(0x20010db8);
501-
ip6->s6_addr32[1] = htonl(0x00000000);
502-
ip6->s6_addr32[2] = htonl(0x00000000);
503-
ip6->s6_addr32[3] = htonl(0x00060006);
507+
ip6->s6_addr[ 0] = 0x20;
508+
ip6->s6_addr[ 1] = 0x01;
509+
ip6->s6_addr[ 2] = 0x0d;
510+
ip6->s6_addr[ 3] = 0xb8;
511+
ip6->s6_addr[ 4] = 0x00;
512+
ip6->s6_addr[ 5] = 0x00;
513+
ip6->s6_addr[ 6] = 0x00;
514+
ip6->s6_addr[ 7] = 0x00;
515+
ip6->s6_addr[ 8] = 0x00;
516+
ip6->s6_addr[ 9] = 0x00;
517+
ip6->s6_addr[10] = 0x00;
518+
ip6->s6_addr[11] = 0x00;
519+
ip6->s6_addr[12] = 0x00;
520+
ip6->s6_addr[13] = 0x06;
521+
ip6->s6_addr[14] = 0x00;
522+
ip6->s6_addr[15] = 0x06;
504523
strcpy(ip, fake);
505524
peer_rc= 0;
506525
}
507526
);
508527
#endif /* HAVE_IPV6 */
509528

529+
/*
530+
===========================================================================
531+
DEBUG code only (end)
532+
===========================================================================
533+
*/
534+
510535
if (peer_rc)
511536
{
512537
/*

0 commit comments

Comments
 (0)