summaryrefslogtreecommitdiff
path: root/sql/sql_connect.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-01-09 23:51:51 +0100
committerSergei Golubchik <sergii@pisem.net>2013-01-09 23:51:51 +0100
commit2e11ca36f28133c18b72351d176ee2fd7fcbc465 (patch)
tree5aefb03db444e9c2856c3aba50f2f28e8fa12772 /sql/sql_connect.cc
parenteff07bf08e29afab76c7688ec063ef6881ee464f (diff)
parentd07b5f1ca295d4eb6eeba0b88c93f04e9e21cb5c (diff)
downloadmariadb-git-2e11ca36f28133c18b72351d176ee2fd7fcbc465.tar.gz
mysql-5.1.67 merge
Diffstat (limited to 'sql/sql_connect.cc')
-rw-r--r--sql/sql_connect.cc40
1 files changed, 35 insertions, 5 deletions
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index 3caaea5bfb7..f8b919b1c38 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -350,6 +350,7 @@ check_user(THD *thd, enum enum_server_command command,
USER_RESOURCES ur;
int res= acl_getroot(thd, &ur, passwd, passwd_len);
+ DBUG_EXECUTE_IF("password_format_mismatch",{res= -1;};);
#ifndef EMBEDDED_LIBRARY
if (res == -1)
{
@@ -360,6 +361,12 @@ check_user(THD *thd, enum enum_server_command command,
in old format.
*/
NET *net= &thd->net;
+ DBUG_EXECUTE_IF("password_format_mismatch",
+ {
+ inc_host_errors(&thd->remote.sin_addr);
+ my_error(ER_HANDSHAKE_ERROR, MYF(0));
+ DBUG_RETURN(1);
+ };);
if (opt_secure_auth_local)
{
my_error(ER_SERVER_IS_IN_SECURE_AUTH_MODE, MYF(0),
@@ -696,6 +703,19 @@ static int check_connection(THD *thd)
my_error(ER_BAD_HOST_ERROR, MYF(0));
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))))
return 1; /* The error is set by my_strdup(). */
thd->main_security_ctx.host_or_ip= thd->main_security_ctx.ip;
@@ -796,8 +816,6 @@ static int check_connection(THD *thd)
#ifdef _CUSTOMCONFIG_
#include "_cust_sql_parse.h"
#endif
- if (connect_errors)
- reset_host_errors(&thd->remote.sin_addr);
if (thd->packet.alloc(thd->variables.net_buffer_length))
return 1; /* The error is set by alloc(). */
@@ -942,11 +960,23 @@ static int check_connection(THD *thd)
user[user_len]= '\0';
}
- if (thd->main_security_ctx.user)
- x_free(thd->main_security_ctx.user);
+ x_free(thd->main_security_ctx.user);
if (!(thd->main_security_ctx.user= my_strdup(user, MYF(MY_WME))))
return 1; /* The error is set by my_strdup(). */
- return check_user(thd, COM_CONNECT, passwd, passwd_len, db, TRUE);
+
+ if (!check_user(thd, COM_CONNECT, passwd, passwd_len, db, TRUE))
+ {
+ /*
+ Call to reset_host_errors() should be made only when all sanity checks
+ are done and connection is going to be a successful.
+ */
+ reset_host_errors(&thd->remote.sin_addr);
+ return 0;
+ }
+ else
+ {
+ return 1;
+ }
error:
inc_host_errors(&thd->remote.sin_addr);