Skip to content

Commit 5f3490a

Browse files
author
Tor Didriksen
committed
Bug#22958632 ASAN: NAME_CONST WITH INVALID IDENTIFIER, HEAP-BUFFER-OVERFLOW
The function append_identifier() might receive bad input, e.g. strings that are not valid according to the given charset/collation. Ensure that it simply quotes the input, and never reads past-the-end of it. Change-Id: I7720678b78879ab768dbe50b0c03c9591cd437f8 (cherry picked from commit c72537c3718f5693174753bb62c97d833ddc2362) (cherry picked from commit 530dd2acd9c0884ee3d50af879a9baeb4cf0ac0c)
1 parent da9c26e commit 5f3490a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sql/sql_show.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,9 @@ void append_identifier(const THD *thd, String *packet, const char *name,
15651565
if (!to_length) to_length = 1;
15661566
if (to_length == 1 && chr == static_cast<uchar>(quote_char))
15671567
packet->append(&quote_char, 1, system_charset_info);
1568-
packet->append(to_name, to_length, system_charset_info);
1568+
packet->append(to_name,
1569+
std::min(to_length, static_cast<size_t>(name_end - to_name)),
1570+
system_charset_info);
15691571
}
15701572
packet->append(&quote_char, 1, system_charset_info);
15711573
}

0 commit comments

Comments
 (0)