1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-36480 USAN: checking identifier names for 0 length names

Identifier names can be empty in the grammar. The check_ident_length
is used from everything from triggers, to partitions, to key names
and UDF names. This change updates 0 length identifiers as valid
without further checking.

Primary keys are one clear case where a empty name is used and
the name.str is a null pointer.

Checking empty names where the key->name.str is a null pointer
results in a UBSAN error in Well_formed_prefix_status further
down the stack which we can avoid.
This commit is contained in:
Daniel Black
2025-04-04 16:22:30 +11:00
parent c06c36218a
commit dca2e5509e

View File

@@ -10389,7 +10389,13 @@ bool check_string_char_length(const LEX_CSTRING *str, uint err_msg,
bool check_ident_length(const LEX_CSTRING *ident)
{
if (check_string_char_length(ident, 0, NAME_CHAR_LEN, system_charset_info, 1))
/*
string_char_length desite the names, goes into Well_formed_prefix_status
so this is more than just a length comparison. Things like a primary key
doesn't have a name, therefore no length. Also the ident grammar allows
empty backtick. Check quickly the length, and if 0, accept that.
*/
if (ident->length && check_string_char_length(ident, 0, NAME_CHAR_LEN, system_charset_info, 1))
{
my_error(ER_TOO_LONG_IDENT, MYF(0), ident->str);
return 1;