mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Bug #30695: An apostrophe ' in the comment of the ADD PARTITION
causes the Server to crash. Accessing partitioned table with an apostrophe in partition options like DATA DIRECTORY, INDEX DIRECTORY or COMMENT causes server crash. Partition options were saved in .frm file without escaping. When accessing such table it is not possible to properly restore partition information. Crashed because there was no check for partition info parser failure. Fixed by escaping quoted text in the partition info when writing it to the frm-file and added a check that it was able to parse the partition info before using it NOTE: If the comment is written by an earlier version of the server, the corrupted frm-file is not fixed, but left corrupted, you have to manually drop the table and recreate it.
This commit is contained in:
@ -1849,6 +1849,20 @@ static int add_uint(File fptr, ulonglong number)
|
||||
return add_string(fptr, buff);
|
||||
}
|
||||
|
||||
/*
|
||||
Must escape strings in partitioned tables frm-files,
|
||||
parsing it later with mysql_unpack_partition will fail otherwise.
|
||||
*/
|
||||
static int add_quoted_string(File fptr, const char *quotestr)
|
||||
{
|
||||
String orgstr(quotestr, system_charset_info);
|
||||
String escapedstr;
|
||||
int err= add_string(fptr, "'");
|
||||
err+= append_escaped(&escapedstr, &orgstr);
|
||||
err+= add_string(fptr, escapedstr.c_ptr());
|
||||
return err + add_string(fptr, "'");
|
||||
}
|
||||
|
||||
static int add_keyword_string(File fptr, const char *keyword,
|
||||
bool should_use_quotes,
|
||||
const char *keystr)
|
||||
@ -1859,10 +1873,9 @@ static int add_keyword_string(File fptr, const char *keyword,
|
||||
err+= add_equal(fptr);
|
||||
err+= add_space(fptr);
|
||||
if (should_use_quotes)
|
||||
err+= add_string(fptr, "'");
|
||||
err+= add_string(fptr, keystr);
|
||||
if (should_use_quotes)
|
||||
err+= add_string(fptr, "'");
|
||||
err+= add_quoted_string(fptr, keystr);
|
||||
else
|
||||
err+= add_string(fptr, keystr);
|
||||
return err + add_space(fptr);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user