Commit d409547d authored by bell@sanja.is.com.ua's avatar bell@sanja.is.com.ua

changed function name to prevent injection wrong code from 4.1 (WL#2133)

parent 4714a6e7
drop table if exists t1, t2, t3, t4;
drop table if exists t1, t2, t3, t4;
start slave;
ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
ERROR HY000: File '/home/bell/mysql/bk/work-error-5.0/mysql-test/var/slave-data/master.info' not found (Errcode: 13)
start slave;
ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log
change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root';
......
......@@ -23,7 +23,7 @@ drop table if exists t1, t2, t3, t4;
# START SLAVE will fail because it can't read the file (mode 000)
# (system error 13)
--error 1201
--error 1105
start slave;
system chmod 600 var/slave-data/master.info;
# It will fail again because the file is empty so the slave cannot get valuable
......
......@@ -2587,7 +2587,7 @@ Slave: load data infile on table '%s' at log position %s in log \
my_afree(load_data_query);
if (thd->query_error)
{
/* this err/sql_errno code is copy-paste from send_error() */
/* this err/sql_errno code is copy-paste from net_send_error() */
const char *err;
int sql_errno;
if ((err=thd->net.last_error)[0])
......
......@@ -1331,7 +1331,7 @@ void close_connection(THD *thd, uint errcode, bool lock)
if ((vio=thd->net.vio) != 0)
{
if (errcode)
send_error(thd, errcode, ER(errcode)); /* purecov: inspected */
net_send_error(thd, errcode, ER(errcode)); /* purecov: inspected */
vio_close(vio); /* vio is freed in delete thd */
}
if (lock)
......@@ -3396,7 +3396,7 @@ static void create_new_thread(THD *thd)
thd->killed= THD::KILL_CONNECTION; // Safety
(void) pthread_mutex_unlock(&LOCK_thread_count);
statistic_increment(aborted_connects,&LOCK_status);
net_printf(thd,ER_CANT_CREATE_THREAD,error);
net_printf_error(thd, ER_CANT_CREATE_THREAD, error);
(void) pthread_mutex_lock(&LOCK_thread_count);
close_connection(thd,0,0);
delete thd;
......
......@@ -53,14 +53,14 @@ bool Protocol_prep::net_store_data(const char *from, uint length)
/* Send a error string to client */
void send_error(THD *thd, uint sql_errno, const char *err)
void net_send_error(THD *thd, uint sql_errno, const char *err)
{
#ifndef EMBEDDED_LIBRARY
uint length;
char buff[MYSQL_ERRMSG_SIZE+2], *pos;
#endif
NET *net= &thd->net;
DBUG_ENTER("send_error");
DBUG_ENTER("net_send_error");
DBUG_PRINT("enter",("sql_errno: %d err: %s", sql_errno,
err ? err : net->last_error[0] ?
net->last_error : "NULL"));
......@@ -169,7 +169,7 @@ void send_warning(THD *thd, uint sql_errno, const char *err)
*/
void
net_printf(THD *thd, uint errcode, ...)
net_printf_error(THD *thd, uint errcode, ...)
{
va_list args;
uint length,offset;
......@@ -182,7 +182,7 @@ net_printf(THD *thd, uint errcode, ...)
#endif
NET *net= &thd->net;
DBUG_ENTER("net_printf");
DBUG_ENTER("net_printf_error");
DBUG_PRINT("enter",("message: %u",errcode));
if (thd->spcont && thd->spcont->find_handler(errcode,
......@@ -196,8 +196,8 @@ net_printf(THD *thd, uint errcode, ...)
#endif
va_start(args,errcode);
/*
The following is needed to make net_printf() work with 0 argument for
errorcode and use the argument after that as the format string. This
The following is needed to make net_printf_error() work with 0 argument
for errorcode and use the argument after that as the format string. This
is useful for rare errors that are not worth the hassle to put in
errmsg.sys, but at the same time, the message is not fixed text
*/
......
......@@ -172,7 +172,8 @@ public:
};
void send_warning(THD *thd, uint sql_errno, const char *err=0);
void net_printf(THD *thd,uint sql_errno, ...);
void net_printf_error(THD *thd, uint sql_errno, ...);
void net_send_error(THD *thd, uint sql_errno=0, const char *err=0);
void send_ok(THD *thd, ha_rows affected_rows=0L, ulonglong id=0L,
const char *info=0);
void send_eof(THD *thd, bool no_flush=0);
......
......@@ -1196,8 +1196,6 @@ public:
class JOIN;
void send_error(THD *thd, uint sql_errno=0, const char *err=0);
class select_result :public Sql_alloc {
protected:
THD *thd;
......
......@@ -165,7 +165,7 @@ static int get_or_create_user_conn(THD *thd, const char *user,
my_malloc(sizeof(struct user_conn) + temp_len+1,
MYF(MY_WME)))))
{
send_error(thd, 0, NullS); // Out of memory
net_send_error(thd, 0, NullS); // Out of memory
return_val=1;
goto end;
}
......@@ -183,7 +183,7 @@ static int get_or_create_user_conn(THD *thd, const char *user,
if (my_hash_insert(&hash_user_connections, (byte*) uc))
{
my_free((char*) uc,0);
send_error(thd, 0, NullS); // Out of memory
net_send_error(thd, 0, NullS); // Out of memory
return_val=1;
goto end;
}
......@@ -258,7 +258,7 @@ int check_user(THD *thd, enum enum_server_command command,
*/
if (opt_secure_auth_local && passwd_len == SCRAMBLE_LENGTH_323)
{
net_printf(thd, ER_NOT_SUPPORTED_AUTH_MODE);
net_printf_error(thd, ER_NOT_SUPPORTED_AUTH_MODE);
mysql_log.write(thd, COM_CONNECT, ER(ER_NOT_SUPPORTED_AUTH_MODE));
DBUG_RETURN(-1);
}
......@@ -290,8 +290,8 @@ int check_user(THD *thd, enum enum_server_command command,
NET *net= &thd->net;
if (opt_secure_auth_local)
{
net_printf(thd, ER_SERVER_IS_IN_SECURE_AUTH_MODE,
thd->user, thd->host_or_ip);
net_printf_error(thd, ER_SERVER_IS_IN_SECURE_AUTH_MODE,
thd->user, thd->host_or_ip);
mysql_log.write(thd, COM_CONNECT, ER(ER_SERVER_IS_IN_SECURE_AUTH_MODE),
thd->user, thd->host_or_ip);
DBUG_RETURN(-1);
......@@ -330,7 +330,7 @@ int check_user(THD *thd, enum enum_server_command command,
VOID(pthread_mutex_unlock(&LOCK_thread_count));
if (!count_ok)
{ // too many connections
send_error(thd, ER_CON_COUNT_ERROR);
net_send_error(thd, ER_CON_COUNT_ERROR);
DBUG_RETURN(-1);
}
}
......@@ -380,14 +380,14 @@ int check_user(THD *thd, enum enum_server_command command,
}
else if (res == 2) // client gave short hash, server has long hash
{
net_printf(thd, ER_NOT_SUPPORTED_AUTH_MODE);
net_printf_error(thd, ER_NOT_SUPPORTED_AUTH_MODE);
mysql_log.write(thd,COM_CONNECT,ER(ER_NOT_SUPPORTED_AUTH_MODE));
DBUG_RETURN(-1);
}
net_printf(thd, ER_ACCESS_DENIED_ERROR,
thd->user,
thd->host_or_ip,
passwd_len ? ER(ER_YES) : ER(ER_NO));
net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
thd->user,
thd->host_or_ip,
passwd_len ? ER(ER_YES) : ER(ER_NO));
mysql_log.write(thd, COM_CONNECT, ER(ER_ACCESS_DENIED_ERROR),
thd->user,
thd->host_or_ip,
......@@ -450,16 +450,16 @@ static int check_for_max_user_connections(THD *thd, USER_CONN *uc)
if (max_user_connections &&
max_user_connections < (uint) uc->connections)
{
net_printf(thd,ER_TOO_MANY_USER_CONNECTIONS, uc->user);
net_printf_error(thd, ER_TOO_MANY_USER_CONNECTIONS, uc->user);
error=1;
goto end;
}
if (uc->user_resources.connections &&
uc->user_resources.connections <= uc->conn_per_hour)
{
net_printf(thd, ER_USER_LIMIT_REACHED, uc->user,
"max_connections",
(long) uc->user_resources.connections);
net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user,
"max_connections",
(long) uc->user_resources.connections);
error=1;
goto end;
}
......@@ -585,8 +585,8 @@ static bool check_mqh(THD *thd, uint check_command)
if (uc->user_resources.questions &&
uc->questions++ >= uc->user_resources.questions)
{
net_printf(thd, ER_USER_LIMIT_REACHED, uc->user, "max_questions",
(long) uc->user_resources.questions);
net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user, "max_questions",
(long) uc->user_resources.questions);
error=1;
goto end;
}
......@@ -596,8 +596,8 @@ static bool check_mqh(THD *thd, uint check_command)
if (uc->user_resources.updates && uc_update_queries[check_command] &&
uc->updates++ >= uc->user_resources.updates)
{
net_printf(thd, ER_USER_LIMIT_REACHED, uc->user, "max_updates",
(long) uc->user_resources.updates);
net_printf_error(thd, ER_USER_LIMIT_REACHED, uc->user, "max_updates",
(long) uc->user_resources.updates);
error=1;
goto end;
}
......@@ -1001,7 +1001,7 @@ pthread_handler_decl(handle_one_connection,arg)
if ((error=check_connection(thd)))
{ // Wrong permissions
if (error > 0)
net_printf(thd,error,thd->host_or_ip);
net_printf_error(thd, error, thd->host_or_ip);
#ifdef __NT__
if (vio_type(net->vio) == VIO_TYPE_NAMEDPIPE)
my_sleep(1000); /* must wait after eof() */
......@@ -1044,7 +1044,7 @@ pthread_handler_decl(handle_one_connection,arg)
thd->host_or_ip,
(net->last_errno ? ER(net->last_errno) :
ER(ER_UNKNOWN_ERROR)));
send_error(thd,net->last_errno,NullS);
net_send_error(thd, net->last_errno, NullS);
statistic_increment(aborted_threads,&LOCK_status);
}
else if (thd->killed)
......@@ -1113,7 +1113,7 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg)
uint length=(uint) strlen(buff);
if (buff[length-1]!='\n' && !feof(file))
{
send_error(thd,ER_NET_PACKET_TOO_LARGE, NullS);
net_send_error(thd, ER_NET_PACKET_TOO_LARGE, NullS);
thd->is_fatal_error= 1;
break;
}
......@@ -1267,7 +1267,7 @@ bool do_command(THD *thd)
statistic_increment(aborted_threads,&LOCK_status);
DBUG_RETURN(TRUE); // We have to close it.
}
send_error(thd,net->last_errno,NullS);
net_send_error(thd, net->last_errno, NullS);
net->error= 0;
DBUG_RETURN(FALSE);
}
......@@ -1808,7 +1808,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (thd->killed_errno() && !thd->net.report_error)
thd->send_kill_message();
if (thd->is_fatal_error || thd->net.report_error)
send_error(thd);
net_send_error(thd);
time_t start_of_query=thd->start_time;
thd->end_time(); // Set start time
......@@ -3671,10 +3671,6 @@ create_error:
goto error;
#ifndef EMBEDDED_LIBRARY
/*
When executing substatements, they're assumed to send_error when
it happens, but not to send_ok.
*/
my_bool nsok= thd->net.no_send_ok;
thd->net.no_send_ok= TRUE;
#endif
......@@ -3932,7 +3928,6 @@ create_error:
DBUG_RETURN(res || thd->net.report_error);
error:
/* We end up here if send_error() has already been done. */
DBUG_RETURN(TRUE);
}
......
......@@ -867,7 +867,7 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report)
if (slave_errno)
{
if (net_report)
send_error(thd, slave_errno);
my_error(slave_errno, MYF(0));
DBUG_RETURN(1);
}
else if (net_report)
......@@ -917,7 +917,7 @@ int stop_slave(THD* thd, MASTER_INFO* mi, bool net_report )
if (slave_errno)
{
if (net_report)
send_error(thd, slave_errno);
my_error(slave_errno, MYF(0));
return 1;
}
else if (net_report)
......
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