mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
MENT-1703 Repeatable crash during backup after processing very large ibdata1
The crash happened in filename_to_spacename() when using it on a filename that is not in the format of "./database/table.ibd". According to Marko, it is possible the function is called with the path to an undo file, which would cause a crash. This patch fixes this by, instead of crashing with unexpected filenames, returning them 'as such', except for changing all '\' to '/'.
This commit is contained in:
@@ -851,28 +851,49 @@ void mdl_lock_all()
|
||||
|
||||
|
||||
// Convert non-null terminated filename to space name
|
||||
// Note that in 10.6 the filename may be an undo file name
|
||||
static std::string filename_to_spacename(const void *filename, size_t len)
|
||||
{
|
||||
// null- terminate filename
|
||||
char *f = (char *)malloc(len + 1);
|
||||
ut_a(f);
|
||||
memcpy(f, filename, len);
|
||||
f[len] = 0;
|
||||
for (size_t i = 0; i < len; i++)
|
||||
if (f[i] == '\\')
|
||||
f[i] = '/';
|
||||
char *p = strrchr(f, '.');
|
||||
ut_a(p);
|
||||
*p = 0;
|
||||
char *table = strrchr(f, '/');
|
||||
ut_a(table);
|
||||
*table = 0;
|
||||
char *db = strrchr(f, '/');
|
||||
ut_a(db);
|
||||
*table = '/';
|
||||
std::string s(db+1);
|
||||
free(f);
|
||||
return s;
|
||||
char f[FN_REFLEN];
|
||||
char *p= 0, *table, *db;
|
||||
DBUG_ASSERT(len = FN_REFLEN);
|
||||
|
||||
strmake(f, (const char*) filename, len);
|
||||
|
||||
#ifdef _WIN32
|
||||
for (size_t i = 0; i < len; i++)
|
||||
{
|
||||
if (f[i] == '\\')
|
||||
f[i] = '/';
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Remove extension, if exists */
|
||||
if (!(p= strrchr(f, '.')))
|
||||
goto err;
|
||||
*p= 0;
|
||||
|
||||
/* Find table name */
|
||||
if (!(table= strrchr(f, '/')))
|
||||
goto err;
|
||||
*table = 0;
|
||||
|
||||
/* Find database name */
|
||||
db= strrchr(f, '/');
|
||||
*table = '/';
|
||||
if (!db)
|
||||
goto err;
|
||||
{
|
||||
std::string s(db+1);
|
||||
return s;
|
||||
}
|
||||
|
||||
err:
|
||||
/* Not a database/table. Return original (converted) name */
|
||||
if (p)
|
||||
*p= '.'; // Restore removed extension
|
||||
std::string s(f);
|
||||
return s;
|
||||
}
|
||||
|
||||
/** Report an operation to create, delete, or rename a file during backup.
|
||||
|
||||
Reference in New Issue
Block a user