mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-34203 Sandbox mode \- is not compatible with --binary-mode
"Process" sandbox short command put by masqldump to avoid an error.
This commit is contained in:
@ -1117,6 +1117,8 @@ inline int get_command_index(char cmd_char)
|
||||
|
||||
static int delimiter_index= -1;
|
||||
static int charset_index= -1;
|
||||
static int sandbox_index= -1;
|
||||
|
||||
static bool real_binary_mode= FALSE;
|
||||
|
||||
|
||||
@ -1128,6 +1130,7 @@ int main(int argc,char *argv[])
|
||||
DBUG_ENTER("main");
|
||||
DBUG_PROCESS(argv[0]);
|
||||
|
||||
sandbox_index= get_command_index('-');
|
||||
charset_index= get_command_index('C');
|
||||
delimiter_index= get_command_index('d');
|
||||
delimiter_str= delimiter;
|
||||
@ -2234,8 +2237,9 @@ static int read_and_execute(bool interactive)
|
||||
|
||||
/**
|
||||
It checks if the input is a short form command. It returns the command's
|
||||
pointer if a command is found, else return NULL. Note that if binary-mode
|
||||
is set, then only \C is searched for.
|
||||
pointer if a command is found, else return NULL.
|
||||
|
||||
Note that if binary-mode is set, then only \C and \- are searched for.
|
||||
|
||||
@param cmd_char A character of one byte.
|
||||
|
||||
@ -2250,13 +2254,23 @@ static COMMANDS *find_command(char cmd_char)
|
||||
int index= -1;
|
||||
|
||||
/*
|
||||
In binary-mode, we disallow all mysql commands except '\C'
|
||||
and DELIMITER.
|
||||
In binary-mode, we disallow all client commands except '\C',
|
||||
DELIMITER (see long comand finding find_command(char *))
|
||||
and '\-' (sandbox, see following comment).
|
||||
*/
|
||||
if (real_binary_mode)
|
||||
{
|
||||
if (cmd_char == 'C')
|
||||
index= charset_index;
|
||||
/*
|
||||
binary-mode enforces stricter controls compared to sandbox mode.
|
||||
Whether sandbox mode is enabled or not is irrelevant when
|
||||
binary-mode is active.
|
||||
The only purpose of processing sandbox mode here is to avoid error
|
||||
messages on files made by mysqldump.
|
||||
*/
|
||||
else if (cmd_char == '-')
|
||||
index= sandbox_index;
|
||||
}
|
||||
else
|
||||
index= get_command_index(cmd_char);
|
||||
@ -2312,6 +2326,12 @@ static COMMANDS *find_command(char *name)
|
||||
len= (uint) strlen(name);
|
||||
|
||||
int index= -1;
|
||||
/*
|
||||
In binary-mode, we disallow all client commands except DELIMITER
|
||||
and short commands '\C' and '\-' (see short command finding
|
||||
find_command(char)).
|
||||
*/
|
||||
|
||||
if (real_binary_mode)
|
||||
{
|
||||
if (is_delimiter_command(name, len))
|
||||
|
@ -658,4 +658,15 @@ tee
|
||||
source
|
||||
^^^
|
||||
3
|
||||
#
|
||||
# MDEV-34203: Sandbox mode \- is not compatible with --binary-mode
|
||||
#
|
||||
create table t1 (a int);
|
||||
drop table t1;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||
drop table t1;
|
||||
# End of 10.5 tests
|
||||
|
@ -757,4 +757,20 @@ source $MYSQL_TMP_DIR/mysql_in;" $MYSQL_TMP_DIR/mysql_in2;
|
||||
--remove_file $MYSQL_TMP_DIR/mysql_in
|
||||
--remove_file $MYSQL_TMP_DIR/mysql_in2
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-34203: Sandbox mode \- is not compatible with --binary-mode
|
||||
--echo #
|
||||
|
||||
create table t1 (a int);
|
||||
|
||||
--exec $MYSQL_DUMP test t1 > $MYSQLTEST_VARDIR/tmp/MDEV-34203.sql
|
||||
|
||||
drop table t1;
|
||||
|
||||
--exec $MYSQL --binary-mode test 2>&1 < $MYSQLTEST_VARDIR/tmp/MDEV-34203.sql
|
||||
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
--remove_file $MYSQLTEST_VARDIR/tmp/MDEV-34203.sql
|
||||
|
||||
--echo # End of 10.5 tests
|
||||
|
Reference in New Issue
Block a user