diff options
author | unknown <bell@sanja.is.com.ua> | 2004-10-20 16:06:54 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-10-20 16:06:54 +0300 |
commit | e3b559938c1a739add9ad1dd2e5c62b8e10ade96 (patch) | |
tree | e563023e47dd6c0ae62a78d011b993bef1d34e85 /sql | |
parent | 066c90563a9fd6151461a5d54d879079acffe279 (diff) | |
download | mariadb-git-e3b559938c1a739add9ad1dd2e5c62b8e10ade96.tar.gz |
changed function name to prevent injection wrong code from 4.1 (WL#2133)
mysql-test/r/rpl_rotate_logs.result:
changed error message
mysql-test/t/rpl_rotate_logs.test:
changed error message
sql/log_event.cc:
changed function name to prevent injection wrong code from 4.1
sql/mysqld.cc:
changed function name to prevent injection wrong code from 4.1
sql/protocol.cc:
changed function name to prevent injection wrong code from 4.1
sql/protocol.h:
changed function name to prevent injection wrong code from 4.1
sql/sql_class.h:
changed function name to prevent injection wrong code from 4.1
sql/sql_parse.cc:
changed function name to prevent injection wrong code from 4.1
sql/sql_repl.cc:
changed function name to prevent injection wrong code from 4.1
Diffstat (limited to 'sql')
-rw-r--r-- | sql/log_event.cc | 2 | ||||
-rw-r--r-- | sql/mysqld.cc | 4 | ||||
-rw-r--r-- | sql/protocol.cc | 12 | ||||
-rw-r--r-- | sql/protocol.h | 3 | ||||
-rw-r--r-- | sql/sql_class.h | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 53 | ||||
-rw-r--r-- | sql/sql_repl.cc | 4 |
7 files changed, 37 insertions, 43 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc index 01dcb2af21c..9c9e600edf0 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -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]) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c408478cb15..f2c235cac99 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -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; diff --git a/sql/protocol.cc b/sql/protocol.cc index c92d25f3f4d..b8414e45c97 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -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 */ diff --git a/sql/protocol.h b/sql/protocol.h index 1a5896a3ae5..b65a666a5b1 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -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); diff --git a/sql/sql_class.h b/sql/sql_class.h index f014a597169..46cf8ca4899 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -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; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 8817a29a705..ed174162db8 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -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); } diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index fe7e8432ec6..16daba09954 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -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) |