1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-34226 On startup: UBSAN: applying zero offset to null pointer in my_copy_fix_mb from strings/ctype-mb.c and other locations

nullptr+0 is an UB (undefined behavior).

- Fixing my_string_metadata_get_mb() to handle {nullptr,0} without UB.
- Fixing THD::copy_with_error() to disallow {nullptr,0} by DBUG_ASSERT().
- Fixing parse_client_handshake_packet() to call THD::copy_with_error()
  with an empty string {"",0} instead of NULL string {nullptr,0}.
This commit is contained in:
Alexander Barkov
2024-05-27 12:46:51 +04:00
parent 7925326183
commit 4a158ec167
5 changed files with 25 additions and 2 deletions

View File

@ -2522,6 +2522,8 @@ bool THD::copy_with_error(CHARSET_INFO *dstcs, LEX_STRING *dst,
CHARSET_INFO *srccs,
const char *src, size_t src_length)
{
// Don't allow NULL to avoid UB in the called functions: nullptr+0
DBUG_ASSERT(src);
String_copier_with_error status;
return copy_fix(dstcs, dst, srccs, src, src_length, &status) ||
status.check_errors(srccs, src, src_length);