Below is the list of changes that have just been committed into a local
5.1 repository of ram. When ram does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-10-16 17:19:07+05:00, ramil@stripped +3 -0
Fix bug #31604: server crash when setting slow_query_log_file/global general_log_file variable
Problem: we don't evaluate given expression checking values of the
slow_query_log_file/general_log_file, don't check it for NULL.
Fix: evaluate the expression, check result returned.
mysql-test/r/log_state.result@stripped, 2007-10-16 17:19:05+05:00, ramil@stripped +13 -0
Fix bug #31604: server crash when setting slow_query_log_file/global general_log_file variable
- test result.
mysql-test/t/log_state.test@stripped, 2007-10-16 17:19:05+05:00, ramil@stripped +20 -0
Fix bug #31604: server crash when setting slow_query_log_file/global general_log_file variable
- test case.
sql/set_var.cc@stripped, 2007-10-16 17:19:05+05:00, ramil@stripped +17 -6
Fix bug #31604: server crash when setting slow_query_log_file/global general_log_file variable
- evaluate var->value calling val_str() method;
- check for null values returned;
- return proper errors if any.
diff -Nrup a/mysql-test/r/log_state.result b/mysql-test/r/log_state.result
--- a/mysql-test/r/log_state.result 2007-08-08 16:49:17 +05:00
+++ b/mysql-test/r/log_state.result 2007-10-16 17:19:05 +05:00
@@ -175,3 +175,16 @@ SET GLOBAL slow_query_log = ON;
SET GLOBAL READ_ONLY = OFF;
SET GLOBAL general_log = @old_general_log_state;
SET GLOBAL slow_query_log = @old_slow_log_state;
+set @old_general_log_file= @@global.general_log_file;
+set @old_slow_query_log_file= @@global.slow_query_log_file;
+set global general_log_file= concat('/not exiting path/log.maste', 'r');
+ERROR 42000: Variable 'general_log_file' can't be set to the value of '/not exiting path/log.master'
+set global general_log_file= NULL;
+ERROR 42000: Variable 'general_log_file' can't be set to the value of 'NULL'
+set global slow_query_log_file= concat('/not exiting path/log.maste', 'r');
+ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of '/not exiting path/log.master'
+set global slow_query_log_file= NULL;
+ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of 'NULL'
+set global general_log_file= @old_general_log_file;
+set global slow_query_log_file= @old_slow_query_log_file;
+End of 5.1 tests
diff -Nrup a/mysql-test/t/log_state.test b/mysql-test/t/log_state.test
--- a/mysql-test/t/log_state.test 2007-08-08 16:49:17 +05:00
+++ b/mysql-test/t/log_state.test 2007-10-16 17:19:05 +05:00
@@ -189,3 +189,23 @@ disconnect con1;
# Remove the log files that was created in the "default location"
# i.e var/run
--remove_file $MYSQLTEST_VARDIR/run/master.log
+
+#
+# Bug #31604: server crash when setting slow_query_log_file/general_log_file
+#
+set @old_general_log_file= @@global.general_log_file;
+set @old_slow_query_log_file= @@global.slow_query_log_file;
+
+--error 1231
+set global general_log_file= concat('/not exiting path/log.maste', 'r');
+--error 1231
+set global general_log_file= NULL;
+--error 1231
+set global slow_query_log_file= concat('/not exiting path/log.maste', 'r');
+--error 1231
+set global slow_query_log_file= NULL;
+
+set global general_log_file= @old_general_log_file;
+set global slow_query_log_file= @old_slow_query_log_file;
+
+--echo End of 5.1 tests
diff -Nrup a/sql/set_var.cc b/sql/set_var.cc
--- a/sql/set_var.cc 2007-10-10 00:56:44 +05:00
+++ b/sql/set_var.cc 2007-10-16 17:19:05 +05:00
@@ -2102,18 +2102,24 @@ void sys_var_log_state::set_default(THD
static int sys_check_log_path(THD *thd, set_var *var)
{
- char path[FN_REFLEN];
+ char path[FN_REFLEN], buff[FN_REFLEN];
MY_STAT f_stat;
- const char *var_path= var->value->str_value.ptr();
+ String str(buff, sizeof(buff), system_charset_info), *res;
+ const char *log_file_str;
+
+ if (!(res= var->value->val_str(&str)))
+ goto err;
+
+ log_file_str= res->c_ptr();
bzero(&f_stat, sizeof(MY_STAT));
- (void) unpack_filename(path, var_path);
+ (void) unpack_filename(path, log_file_str);
if (my_stat(path, &f_stat, MYF(0)))
{
/* Check if argument is a file and we have 'write' permission */
if (!MY_S_ISREG(f_stat.st_mode) ||
!(f_stat.st_mode & MY_S_IWRITE))
- return -1;
+ goto err;
}
else
{
@@ -2122,11 +2128,16 @@ static int sys_check_log_path(THD *thd,
Check if directory exists and
we have permission to create file & write to file
*/
- (void) dirname_part(path, var_path, &path_length);
+ (void) dirname_part(path, log_file_str, &path_length);
if (my_access(path, (F_OK|W_OK)))
- return -1;
+ goto err;
}
return 0;
+
+err:
+ my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->var->name,
+ res ? log_file_str : "NULL");
+ return 1;
}
| Thread |
|---|
| • bk commit into 5.1 tree (ramil:1.2583) BUG#31604 | ramil | 16 Oct |