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

MDEV-33158: UBSAN via MYSQL_THDVAR_U{INT,LONG{,LONG}}

In plugins, use the correct resolver for ULONG and ULONGLONG
types.

InnoDB has a UINT type as evidenced by "Unknown variable type code 0x182
in plugin 'InnoDB'." so the implementation for UNSIGNED INT was added.

Any InnoDB mtr test that changes lock_wait_timeout,
spider_param_force_commit and some MyRocks unsigned thread server
variables can verify this change is correct.

Reviewer: Brandon Nesterenko
This commit is contained in:
Daniel Black
2025-01-09 18:15:41 +11:00
parent f60a8a680e
commit d7f27d7172

View File

@ -3227,6 +3227,11 @@ static int *mysql_sys_var_int(THD* thd, int offset)
return (int *) intern_sys_var_ptr(thd, offset, true);
}
static unsigned int *mysql_sys_var_uint(THD* thd, int offset)
{
return (unsigned int *) intern_sys_var_ptr(thd, offset, true);
}
static long *mysql_sys_var_long(THD* thd, int offset)
{
return (long *) intern_sys_var_ptr(thd, offset, true);
@ -3897,19 +3902,28 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp,
continue;
if (!(register_var(plugin_name_ptr, opt->name, opt->flags)))
continue;
switch (opt->flags & PLUGIN_VAR_TYPEMASK) {
switch (opt->flags & (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_UNSIGNED)) {
case PLUGIN_VAR_BOOL:
((thdvar_bool_t *) opt)->resolve= mysql_sys_var_char;
break;
case PLUGIN_VAR_INT:
((thdvar_int_t *) opt)->resolve= mysql_sys_var_int;
break;
case PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED:
((thdvar_uint_t *) opt)->resolve= mysql_sys_var_uint;
break;
case PLUGIN_VAR_LONG:
((thdvar_long_t *) opt)->resolve= mysql_sys_var_long;
break;
case PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED:
((thdvar_ulong_t *) opt)->resolve= mysql_sys_var_ulong;
break;
case PLUGIN_VAR_LONGLONG:
((thdvar_longlong_t *) opt)->resolve= mysql_sys_var_longlong;
break;
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED:
((thdvar_ulonglong_t *) opt)->resolve= mysql_sys_var_ulonglong;
break;
case PLUGIN_VAR_STR:
((thdvar_str_t *) opt)->resolve= mysql_sys_var_str;
break;