Fixed bug #32034: On 64bit platforms assigning values of
storage engine system variables was not validated and unexpected value was assigned. The check_func_enum function used subtraction from the uint value with the probably negative result. That result of type uint was compared with 0 after casting to signed long type. On architectures where long type is longer than int type the result of comparison was unexpected.
This commit is contained in:
parent
19c3bd89f8
commit
70f36562bc
@ -17,3 +17,13 @@ UNINSTALL PLUGIN EXAMPLE;
|
|||||||
ERROR 42000: PLUGIN EXAMPLE does not exist
|
ERROR 42000: PLUGIN EXAMPLE does not exist
|
||||||
UNINSTALL PLUGIN non_exist;
|
UNINSTALL PLUGIN non_exist;
|
||||||
ERROR 42000: PLUGIN non_exist does not exist
|
ERROR 42000: PLUGIN non_exist does not exist
|
||||||
|
#
|
||||||
|
# Bug#32034: check_func_enum() does not check correct values but set it
|
||||||
|
# to impossible int val
|
||||||
|
#
|
||||||
|
INSTALL PLUGIN example SONAME 'ha_example.so';
|
||||||
|
SET GLOBAL example_enum_var= e1;
|
||||||
|
SET GLOBAL example_enum_var= e2;
|
||||||
|
SET GLOBAL example_enum_var= impossible;
|
||||||
|
ERROR 42000: Variable 'enum_var' can't be set to the value of 'impossible'
|
||||||
|
UNINSTALL PLUGIN example;
|
||||||
|
@ -24,3 +24,18 @@ UNINSTALL PLUGIN EXAMPLE;
|
|||||||
|
|
||||||
--error 1305
|
--error 1305
|
||||||
UNINSTALL PLUGIN non_exist;
|
UNINSTALL PLUGIN non_exist;
|
||||||
|
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Bug#32034: check_func_enum() does not check correct values but set it
|
||||||
|
--echo # to impossible int val
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
INSTALL PLUGIN example SONAME 'ha_example.so';
|
||||||
|
|
||||||
|
SET GLOBAL example_enum_var= e1;
|
||||||
|
SET GLOBAL example_enum_var= e2;
|
||||||
|
--error 1231
|
||||||
|
SET GLOBAL example_enum_var= impossible;
|
||||||
|
|
||||||
|
UNINSTALL PLUGIN example;
|
||||||
|
@ -1944,7 +1944,7 @@ static int check_func_enum(THD *thd, struct st_mysql_sys_var *var,
|
|||||||
length= sizeof(buff);
|
length= sizeof(buff);
|
||||||
if (!(str= value->val_str(value, buff, &length)))
|
if (!(str= value->val_str(value, buff, &length)))
|
||||||
goto err;
|
goto err;
|
||||||
if ((result= find_type(typelib, str, length, 1)-1) < 0)
|
if ((result= (long)find_type(typelib, str, length, 1)-1) < 0)
|
||||||
{
|
{
|
||||||
strvalue= str;
|
strvalue= str;
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -848,6 +848,34 @@ int ha_example::create(const char *name, TABLE *table_arg,
|
|||||||
struct st_mysql_storage_engine example_storage_engine=
|
struct st_mysql_storage_engine example_storage_engine=
|
||||||
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
|
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
|
||||||
|
|
||||||
|
static ulong srv_enum_var= 0;
|
||||||
|
|
||||||
|
const char *enum_var_names[]=
|
||||||
|
{
|
||||||
|
"e1", "e2", NullS
|
||||||
|
};
|
||||||
|
|
||||||
|
TYPELIB enum_var_typelib=
|
||||||
|
{
|
||||||
|
array_elements(enum_var_names) - 1, "enum_var_typelib",
|
||||||
|
enum_var_names, NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static MYSQL_SYSVAR_ENUM(
|
||||||
|
enum_var, // name
|
||||||
|
srv_enum_var, // varname
|
||||||
|
PLUGIN_VAR_RQCMDARG, // opt
|
||||||
|
"Sample ENUM system variable.", // comment
|
||||||
|
NULL, // check
|
||||||
|
NULL, // update
|
||||||
|
0, // def
|
||||||
|
&enum_var_typelib); // typelib
|
||||||
|
|
||||||
|
static struct st_mysql_sys_var* example_system_variables[]= {
|
||||||
|
MYSQL_SYSVAR(enum_var),
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
mysql_declare_plugin(example)
|
mysql_declare_plugin(example)
|
||||||
{
|
{
|
||||||
MYSQL_STORAGE_ENGINE_PLUGIN,
|
MYSQL_STORAGE_ENGINE_PLUGIN,
|
||||||
@ -860,7 +888,7 @@ mysql_declare_plugin(example)
|
|||||||
example_done_func, /* Plugin Deinit */
|
example_done_func, /* Plugin Deinit */
|
||||||
0x0001 /* 0.1 */,
|
0x0001 /* 0.1 */,
|
||||||
NULL, /* status variables */
|
NULL, /* status variables */
|
||||||
NULL, /* system variables */
|
example_system_variables, /* system variables */
|
||||||
NULL /* config options */
|
NULL /* config options */
|
||||||
}
|
}
|
||||||
mysql_declare_plugin_end;
|
mysql_declare_plugin_end;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user