Skip to content

Commit 2a54a53

Browse files
committed
MDEV-10465 general_log_file can be abused
followup
1 parent a7c43a6 commit 2a54a53

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

mysql-test/suite/sys_vars/r/general_log_file_basic.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ SET @@global.general_log_file = '/tmp/my.cnf';
1818
ERROR 42000: Variable 'general_log_file' can't be set to the value of '/tmp/my.cnf'
1919
SET @@global.general_log_file = '.my.cnf';
2020
ERROR 42000: Variable 'general_log_file' can't be set to the value of '.my.cnf'
21+
SET @@global.general_log_file = 'my.cnf\0foo';
22+
ERROR 42000: Variable 'general_log_file' can't be set to the value of 'my.cnf'
2123
'#----------------------FN_DYNVARS_004_03------------------------#'
2224
SELECT @@global.general_log_file = VARIABLE_VALUE
2325
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES

mysql-test/suite/sys_vars/r/slow_query_log_file_basic.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ SET @@global.slow_query_log_file = '/tmp/my.cnf';
1515
ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of '/tmp/my.cnf'
1616
SET @@global.general_log_file = '.my.cnf';
1717
ERROR 42000: Variable 'general_log_file' can't be set to the value of '.my.cnf'
18+
SET @@global.general_log_file = 'my.cnf\0foo';
19+
ERROR 42000: Variable 'general_log_file' can't be set to the value of 'my.cnf'
1820
'#----------------------FN_DYNVARS_004_03------------------------#'
1921
SELECT @@global.slow_query_log_file = VARIABLE_VALUE
2022
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES

mysql-test/suite/sys_vars/t/general_log_file_basic.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ SET @@global.general_log_file = 'my.cnf';
6767
SET @@global.general_log_file = '/tmp/my.cnf';
6868
--error ER_WRONG_VALUE_FOR_VAR
6969
SET @@global.general_log_file = '.my.cnf';
70+
--error ER_WRONG_VALUE_FOR_VAR
71+
SET @@global.general_log_file = 'my.cnf\0foo';
7072

7173

7274
--echo '#----------------------FN_DYNVARS_004_03------------------------#'

mysql-test/suite/sys_vars/t/slow_query_log_file_basic.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ SET @@global.slow_query_log_file = 'my.cnf';
6565
SET @@global.slow_query_log_file = '/tmp/my.cnf';
6666
--error ER_WRONG_VALUE_FOR_VAR
6767
SET @@global.general_log_file = '.my.cnf';
68+
--error ER_WRONG_VALUE_FOR_VAR
69+
SET @@global.general_log_file = 'my.cnf\0foo';
6870

6971
--echo '#----------------------FN_DYNVARS_004_03------------------------#'
7072
##############################################################################

sql/sys_vars.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,19 +3033,19 @@ static bool check_log_path(sys_var *self, THD *thd, set_var *var)
30333033
return true;
30343034
}
30353035

3036-
static const LEX_CSTRING my_cnf= { STRING_WITH_LEN("my.cnf") };
3037-
if (val->length >= my_cnf.length)
3038-
{
3039-
if (strcasecmp(val->str + val->length - my_cnf.length, my_cnf.str) == 0)
3040-
return true; // log file name ends with "my.cnf"
3041-
}
3042-
30433036
char path[FN_REFLEN];
30443037
size_t path_length= unpack_filename(path, val->str);
30453038

30463039
if (!path_length)
30473040
return true;
30483041

3042+
static const LEX_CSTRING my_cnf= { STRING_WITH_LEN("my.cnf") };
3043+
if (path_length >= my_cnf.length)
3044+
{
3045+
if (strcasecmp(path + path_length - my_cnf.length, my_cnf.str) == 0)
3046+
return true; // log file name ends with "my.cnf"
3047+
}
3048+
30493049
MY_STAT f_stat;
30503050

30513051
if (my_stat(path, &f_stat, MYF(0)))

0 commit comments

Comments
 (0)