Commit 77c4c0f2 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-34203 Sandbox mode \- is not compatible with --binary-mode

"Process" sandbox short command put by masqldump to avoid an error.
parent d9d0e8fd
...@@ -1117,6 +1117,8 @@ inline int get_command_index(char cmd_char) ...@@ -1117,6 +1117,8 @@ inline int get_command_index(char cmd_char)
static int delimiter_index= -1; static int delimiter_index= -1;
static int charset_index= -1; static int charset_index= -1;
static int sandbox_index= -1;
static bool real_binary_mode= FALSE; static bool real_binary_mode= FALSE;
...@@ -1128,6 +1130,7 @@ int main(int argc,char *argv[]) ...@@ -1128,6 +1130,7 @@ int main(int argc,char *argv[])
DBUG_ENTER("main"); DBUG_ENTER("main");
DBUG_PROCESS(argv[0]); DBUG_PROCESS(argv[0]);
sandbox_index= get_command_index('-');
charset_index= get_command_index('C'); charset_index= get_command_index('C');
delimiter_index= get_command_index('d'); delimiter_index= get_command_index('d');
delimiter_str= delimiter; delimiter_str= delimiter;
...@@ -2234,8 +2237,9 @@ static int read_and_execute(bool interactive) ...@@ -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 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 pointer if a command is found, else return NULL.
is set, then only \C is searched for.
Note that if binary-mode is set, then only \C and \- are searched for.
@param cmd_char A character of one byte. @param cmd_char A character of one byte.
...@@ -2250,13 +2254,23 @@ static COMMANDS *find_command(char cmd_char) ...@@ -2250,13 +2254,23 @@ static COMMANDS *find_command(char cmd_char)
int index= -1; int index= -1;
/* /*
In binary-mode, we disallow all mysql commands except '\C' In binary-mode, we disallow all client commands except '\C',
and DELIMITER. DELIMITER (see long comand finding find_command(char *))
and '\-' (sandbox, see following comment).
*/ */
if (real_binary_mode) if (real_binary_mode)
{ {
if (cmd_char == 'C') if (cmd_char == 'C')
index= charset_index; 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 else
index= get_command_index(cmd_char); index= get_command_index(cmd_char);
...@@ -2312,6 +2326,12 @@ static COMMANDS *find_command(char *name) ...@@ -2312,6 +2326,12 @@ static COMMANDS *find_command(char *name)
len= (uint) strlen(name); len= (uint) strlen(name);
int index= -1; 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 (real_binary_mode)
{ {
if (is_delimiter_command(name, len)) if (is_delimiter_command(name, len))
......
...@@ -658,4 +658,15 @@ tee ...@@ -658,4 +658,15 @@ tee
source source
^^^ ^^^
3 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 # End of 10.5 tests
...@@ -757,4 +757,20 @@ source $MYSQL_TMP_DIR/mysql_in;" $MYSQL_TMP_DIR/mysql_in2; ...@@ -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_in
--remove_file $MYSQL_TMP_DIR/mysql_in2 --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 --echo # End of 10.5 tests
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment