Skip to content

Commit 470f259

Browse files
committed
MDEV-10465 general_log_file can be abused
This issue was discovered by Dawid Golunski (http://legalhackers.com)
1 parent 0214115 commit 470f259

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ SET @@global.general_log_file = mytest.log;
1212
ERROR 42000: Incorrect argument type to variable 'general_log_file'
1313
SET @@global.general_log_file = 12;
1414
ERROR 42000: Incorrect argument type to variable 'general_log_file'
15+
SET @@global.general_log_file = 'my.cnf';
16+
ERROR 42000: Variable 'general_log_file' can't be set to the value of 'my.cnf'
17+
SET @@global.general_log_file = '/tmp/my.cnf';
18+
ERROR 42000: Variable 'general_log_file' can't be set to the value of '/tmp/my.cnf'
19+
SET @@global.general_log_file = '.my.cnf';
20+
ERROR 42000: Variable 'general_log_file' can't be set to the value of '.my.cnf'
1521
'#----------------------FN_DYNVARS_004_03------------------------#'
1622
SELECT @@global.general_log_file = VARIABLE_VALUE
1723
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ SET @@global.slow_query_log_file = mytest.log;
99
ERROR 42000: Incorrect argument type to variable 'slow_query_log_file'
1010
SET @@global.slow_query_log_file = 12;
1111
ERROR 42000: Incorrect argument type to variable 'slow_query_log_file'
12+
SET @@global.slow_query_log_file = 'my.cnf';
13+
ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of 'my.cnf'
14+
SET @@global.slow_query_log_file = '/tmp/my.cnf';
15+
ERROR 42000: Variable 'slow_query_log_file' can't be set to the value of '/tmp/my.cnf'
16+
SET @@global.general_log_file = '.my.cnf';
17+
ERROR 42000: Variable 'general_log_file' can't be set to the value of '.my.cnf'
1218
'#----------------------FN_DYNVARS_004_03------------------------#'
1319
SELECT @@global.slow_query_log_file = VARIABLE_VALUE
1420
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ SET @@global.general_log_file = mytest.log;
5858
--error ER_WRONG_TYPE_FOR_VAR
5959
SET @@global.general_log_file = 12;
6060

61+
#
62+
# MDEV-10465
63+
#
64+
--error ER_WRONG_VALUE_FOR_VAR
65+
SET @@global.general_log_file = 'my.cnf';
66+
--error ER_WRONG_VALUE_FOR_VAR
67+
SET @@global.general_log_file = '/tmp/my.cnf';
68+
--error ER_WRONG_VALUE_FOR_VAR
69+
SET @@global.general_log_file = '.my.cnf';
70+
6171

6272
--echo '#----------------------FN_DYNVARS_004_03------------------------#'
6373
##############################################################################

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ SET @@global.slow_query_log_file = mytest.log;
5656
--error ER_WRONG_TYPE_FOR_VAR
5757
SET @@global.slow_query_log_file = 12;
5858

59+
#
60+
# MDEV-10465
61+
#
62+
--error ER_WRONG_VALUE_FOR_VAR
63+
SET @@global.slow_query_log_file = 'my.cnf';
64+
--error ER_WRONG_VALUE_FOR_VAR
65+
SET @@global.slow_query_log_file = '/tmp/my.cnf';
66+
--error ER_WRONG_VALUE_FOR_VAR
67+
SET @@global.general_log_file = '.my.cnf';
68+
5969
--echo '#----------------------FN_DYNVARS_004_03------------------------#'
6070
##############################################################################
6171
# Check if the value in GLOBAL Tables matches values in variable #

sql/sys_vars.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,6 +3033,13 @@ 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+
30363043
char path[FN_REFLEN];
30373044
size_t path_length= unpack_filename(path, val->str);
30383045

0 commit comments

Comments
 (0)