1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

Fix for MDEV-14141 Crash in print_keydup_error()

May also fix: MDEV-14970 "MariaDB crashed with signal 11 and Aria table"

I am not able to reproduce a crash, however there was no protection in
print_keydup_error() if the storage engine reported the wrong key number.

This patch adds such a protection and should stop any further crashes
in this case.

Other things:
- Added extra protection in Aria to not set errkey to more than number of
  keys. (Don't think this is cause of this crash, but better safe than
  sorry)
- Extend test_if_equal_repl_errors() to handle different cases of
  ER_DUP_ENTRY. This is just mainly precaution for the future.
This commit is contained in:
Monty
2018-01-23 19:21:44 +02:00
parent a4663af05c
commit b3c7cf81e3
6 changed files with 22 additions and 16 deletions

View File

@@ -3338,9 +3338,11 @@ void print_keydup_error(TABLE *table, KEY *key, const char *msg, myf errflag)
if (key == NULL)
{
/* Key is unknown */
str.copy("", 0, system_charset_info);
my_printf_error(ER_DUP_ENTRY, msg, errflag, str.c_ptr(), "*UNKNOWN*");
/*
Key is unknown. Should only happen if storage engine reports wrong
duplicate key number.
*/
my_printf_error(ER_DUP_ENTRY, msg, errflag, "", "*UNKNOWN*");
}
else
{
@@ -3432,11 +3434,9 @@ void handler::print_error(int error, myf errflag)
if (table)
{
uint key_nr=get_dup_key(error);
if ((int) key_nr >= 0)
if ((int) key_nr >= 0 && key_nr < table->s->keys)
{
print_keydup_error(table,
key_nr == MAX_KEY ? NULL : &table->key_info[key_nr],
errflag);
print_keydup_error(table, &table->key_info[key_nr], errflag);
DBUG_VOID_RETURN;
}
}