Commit 59b4c55b authored by Harin Vadodaria's avatar Harin Vadodaria

Bug#11753779: MAX_CONNECT_ERRORS WORKS ONLY WHEN 1ST

              INC_HOST_ERRORS() IS CALLED.
      
Description: Merge from MySQL 5.1 to MySQL 5.5
             Reverting patch 3869 for bug#11753779
parents bd223999 61e428eb
...@@ -366,14 +366,6 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage, ...@@ -366,14 +366,6 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
err_code= vio_getnameinfo(ip, hostname_buffer, NI_MAXHOST, NULL, 0, err_code= vio_getnameinfo(ip, hostname_buffer, NI_MAXHOST, NULL, 0,
NI_NAMEREQD); NI_NAMEREQD);
/* BEGIN : DEBUG */
DBUG_EXECUTE_IF("addr_fake_ipv4",
{
strcpy(hostname_buffer, "santa.claus.ipv4.example.com");
err_code= 0;
};);
/* END : DEBUG */
if (err_code) if (err_code)
{ {
// NOTE: gai_strerror() returns a string ending by a dot. // NOTE: gai_strerror() returns a string ending by a dot.
...@@ -446,12 +438,6 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage, ...@@ -446,12 +438,6 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
DBUG_RETURN(err_status); DBUG_RETURN(err_status);
} }
/*
To avoid crashing the server in DBUG_EXECUTE_IF,
Define a variable which depicts state of addr_info_list.
*/
bool free_addr_info_list= false;
/* Get IP-addresses for the resolved host name (FCrDNS technique). */ /* Get IP-addresses for the resolved host name (FCrDNS technique). */
struct addrinfo hints; struct addrinfo hints;
...@@ -466,42 +452,6 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage, ...@@ -466,42 +452,6 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
(const char *) hostname_buffer)); (const char *) hostname_buffer));
err_code= getaddrinfo(hostname_buffer, NULL, &hints, &addr_info_list); err_code= getaddrinfo(hostname_buffer, NULL, &hints, &addr_info_list);
if (err_code == 0)
free_addr_info_list= true;
/* BEGIN : DEBUG */
DBUG_EXECUTE_IF("addr_fake_ipv4",
{
if (free_addr_info_list)
freeaddrinfo(addr_info_list);
struct sockaddr_in *debug_addr;
static struct sockaddr_in debug_sock_addr[2];
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;
debug_addr->sin_addr.s_addr= inet_addr("192.0.2.5");
/* Simulating ipv4 192.0.2.4 */
debug_addr= & debug_sock_addr[1];
debug_addr->sin_family= AF_INET;
debug_addr->sin_addr.s_addr= inet_addr("192.0.2.4");
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;
addr_info_list= & debug_addr_info[0];
err_code= 0;
free_addr_info_list= false;
};);
/* END : DEBUG */
if (err_code == EAI_NONAME) if (err_code == EAI_NONAME)
{ {
...@@ -554,7 +504,6 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage, ...@@ -554,7 +504,6 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
{ {
DBUG_PRINT("error", ("Out of memory.")); DBUG_PRINT("error", ("Out of memory."));
if (free_addr_info_list)
freeaddrinfo(addr_info_list); freeaddrinfo(addr_info_list);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
...@@ -589,7 +538,6 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage, ...@@ -589,7 +538,6 @@ bool ip_to_hostname(struct sockaddr_storage *ip_storage,
/* Free the result of getaddrinfo(). */ /* Free the result of getaddrinfo(). */
if (free_addr_info_list)
freeaddrinfo(addr_info_list); freeaddrinfo(addr_info_list);
/* Add an entry for the IP to the cache. */ /* Add an entry for the IP to the cache. */
......
...@@ -8539,6 +8539,8 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio, ...@@ -8539,6 +8539,8 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
bool packet_has_required_size= false; bool packet_has_required_size= false;
DBUG_ASSERT(mpvio->status == MPVIO_EXT::FAILURE); DBUG_ASSERT(mpvio->status == MPVIO_EXT::FAILURE);
if (mpvio->connect_errors)
reset_host_errors(mpvio->ip);
uint charset_code= 0; uint charset_code= 0;
end= (char *)net->read_pos; end= (char *)net->read_pos;
...@@ -8549,11 +8551,6 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio, ...@@ -8549,11 +8551,6 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
*/ */
size_t bytes_remaining_in_packet= pkt_len; size_t bytes_remaining_in_packet= pkt_len;
DBUG_EXECUTE_IF("host_error_packet_length",
{
bytes_remaining_in_packet= 0;
};);
/* /*
Peek ahead on the client capability packet and determine which version of Peek ahead on the client capability packet and determine which version of
the protocol should be used. the protocol should be used.
...@@ -8611,11 +8608,6 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio, ...@@ -8611,11 +8608,6 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
*/ */
charset_code= default_charset_info->number; charset_code= default_charset_info->number;
} }
DBUG_EXECUTE_IF("host_error_charset",
{
return packet_error;
};);
DBUG_PRINT("info", ("client_character_set: %u", charset_code)); DBUG_PRINT("info", ("client_character_set: %u", charset_code));
if (mpvio->charset_adapter->init_client_charset(charset_code)) if (mpvio->charset_adapter->init_client_charset(charset_code))
...@@ -8678,11 +8670,6 @@ skip_to_ssl: ...@@ -8678,11 +8670,6 @@ skip_to_ssl:
bytes_remaining_in_packet -= AUTH_PACKET_HEADER_SIZE_PROTO_40; bytes_remaining_in_packet -= AUTH_PACKET_HEADER_SIZE_PROTO_40;
} }
DBUG_EXECUTE_IF("host_error_SSL_layering",
{
packet_has_required_size= 0;
};);
if (!packet_has_required_size) if (!packet_has_required_size)
return packet_error; return packet_error;
} }
...@@ -8714,11 +8701,6 @@ skip_to_ssl: ...@@ -8714,11 +8701,6 @@ skip_to_ssl:
size_t user_len; size_t user_len;
char *user= get_string(&end, &bytes_remaining_in_packet, &user_len); char *user= get_string(&end, &bytes_remaining_in_packet, &user_len);
DBUG_EXECUTE_IF("host_error_user",
{
user= NULL;
};);
if (user == NULL) if (user == NULL)
return packet_error; return packet_error;
...@@ -8746,11 +8728,6 @@ skip_to_ssl: ...@@ -8746,11 +8728,6 @@ skip_to_ssl:
passwd= get_string(&end, &bytes_remaining_in_packet, &passwd_len); passwd= get_string(&end, &bytes_remaining_in_packet, &passwd_len);
} }
DBUG_EXECUTE_IF("host_error_password",
{
passwd= NULL;
};);
if (passwd == NULL) if (passwd == NULL)
return packet_error; return packet_error;
...@@ -9047,15 +9024,7 @@ static int server_mpvio_read_packet(MYSQL_PLUGIN_VIO *param, uchar **buf) ...@@ -9047,15 +9024,7 @@ static int server_mpvio_read_packet(MYSQL_PLUGIN_VIO *param, uchar **buf)
goto err; goto err;
} }
else else
{
/*
Reset previous connection failures if any.
*/
if (mpvio->connect_errors)
reset_host_errors(mpvio->ip);
*buf= mpvio->net->read_pos; *buf= mpvio->net->read_pos;
}
DBUG_RETURN((int)pkt_len); DBUG_RETURN((int)pkt_len);
......
...@@ -499,19 +499,6 @@ static int check_connection(THD *thd) ...@@ -499,19 +499,6 @@ static int check_connection(THD *thd)
my_error(ER_BAD_HOST_ERROR, MYF(0)); my_error(ER_BAD_HOST_ERROR, MYF(0));
return 1; return 1;
} }
/* BEGIN : DEBUG */
DBUG_EXECUTE_IF("addr_fake_ipv4",
{
struct sockaddr *sa= (sockaddr *) &net->vio->remote;
sa->sa_family= AF_INET;
struct in_addr *ip4= &((struct sockaddr_in *)sa)->sin_addr;
/* See RFC 5737, 192.0.2.0/23 is reserved */
const char* fake= "192.0.2.4";
ip4->s_addr= inet_addr(fake);
strcpy(ip, fake);
};);
/* END : DEBUG */
if (!(thd->main_security_ctx.ip= my_strdup(ip,MYF(MY_WME)))) if (!(thd->main_security_ctx.ip= my_strdup(ip,MYF(MY_WME))))
return 1; /* The error is set by my_strdup(). */ return 1; /* The error is set by my_strdup(). */
thd->main_security_ctx.host_or_ip= thd->main_security_ctx.ip; thd->main_security_ctx.host_or_ip= thd->main_security_ctx.ip;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment