Skip to content

Commit

Permalink
MDEV-33158: UBSAN via MYSQL_THDVAR_U{INT,LONG{,LONG}}
Browse files Browse the repository at this point in the history
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 implemntation for UNSIGNED INT was added.
  • Loading branch information
grooverdan committed Jan 9, 2025
1 parent c898a9e commit 50ebc21
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion sql/sql_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 50ebc21

Please sign in to comment.