@@ -1117,6 +1117,8 @@ inline int get_command_index(char cmd_char)
1117
1117
1118
1118
static int delimiter_index= -1 ;
1119
1119
static int charset_index= -1 ;
1120
+ static int sandbox_index= -1 ;
1121
+
1120
1122
static bool real_binary_mode= FALSE ;
1121
1123
1122
1124
@@ -1127,7 +1129,8 @@ int main(int argc,char *argv[])
1127
1129
MY_INIT (argv[0 ]);
1128
1130
DBUG_ENTER (" main" );
1129
1131
DBUG_PROCESS (argv[0 ]);
1130
-
1132
+
1133
+ sandbox_index= get_command_index (' -' );
1131
1134
charset_index= get_command_index (' C' );
1132
1135
delimiter_index= get_command_index (' d' );
1133
1136
delimiter_str= delimiter;
@@ -2234,8 +2237,9 @@ static int read_and_execute(bool interactive)
2234
2237
2235
2238
/* *
2236
2239
It checks if the input is a short form command. It returns the command's
2237
- pointer if a command is found, else return NULL. Note that if binary-mode
2238
- is set, then only \C is searched for.
2240
+ pointer if a command is found, else return NULL.
2241
+
2242
+ Note that if binary-mode is set, then only \C and \- are searched for.
2239
2243
2240
2244
@param cmd_char A character of one byte.
2241
2245
@@ -2250,13 +2254,23 @@ static COMMANDS *find_command(char cmd_char)
2250
2254
int index= -1 ;
2251
2255
2252
2256
/*
2253
- In binary-mode, we disallow all mysql commands except '\C'
2254
- and DELIMITER.
2257
+ In binary-mode, we disallow all client commands except '\C',
2258
+ DELIMITER (see long comand finding find_command(char *))
2259
+ and '\-' (sandbox, see following comment).
2255
2260
*/
2256
2261
if (real_binary_mode)
2257
2262
{
2258
2263
if (cmd_char == ' C' )
2259
2264
index= charset_index;
2265
+ /*
2266
+ binary-mode enforces stricter controls compared to sandbox mode.
2267
+ Whether sandbox mode is enabled or not is irrelevant when
2268
+ binary-mode is active.
2269
+ The only purpose of processing sandbox mode here is to avoid error
2270
+ messages on files made by mysqldump.
2271
+ */
2272
+ else if (cmd_char == ' -' )
2273
+ index= sandbox_index;
2260
2274
}
2261
2275
else
2262
2276
index= get_command_index (cmd_char);
@@ -2312,6 +2326,12 @@ static COMMANDS *find_command(char *name)
2312
2326
len= (uint) strlen (name);
2313
2327
2314
2328
int index= -1 ;
2329
+ /*
2330
+ In binary-mode, we disallow all client commands except DELIMITER
2331
+ and short commands '\C' and '\-' (see short command finding
2332
+ find_command(char)).
2333
+ */
2334
+
2315
2335
if (real_binary_mode)
2316
2336
{
2317
2337
if (is_delimiter_command (name, len))
0 commit comments