summaryrefslogtreecommitdiff
path: root/sql/sql_plugin.cc
diff options
context:
space:
mode:
authorTatiana A. Nurnberg <azundris@mysql.com>2009-10-27 06:16:02 -0700
committerTatiana A. Nurnberg <azundris@mysql.com>2009-10-27 06:16:02 -0700
commit0ba101d4ea8cc081142288a47bdd4e10d83219e9 (patch)
tree090cd6c0c8479ef071f1edabbf4b79c396257a4a /sql/sql_plugin.cc
parent6ceaf234bb9fa2e521c67568e1bd6f76ac890ee2 (diff)
downloadmariadb-git-0ba101d4ea8cc081142288a47bdd4e10d83219e9.tar.gz
Bug#46586: When using the plugin interface the type "set" for options caused a crash.
"What do you mean, there's a bug? There isn't even code!" There was some token code for plug-in variables of the SET type, but clearly this never worked, or was subject to massive bit rot since. Bug-fixes ... fail-safes ... tests -- fais au mieux, mon chou! mysys/my_getopt.c: SETs set-up should set up a default value, but no min/max bounding. mysys/typelib.c: fail-safe requested by serg: don't try to skip separator when we're already at end of string. sql/sql_plugin.cc: check_func_set: Initialize error_len as find_set() will only update it on error, and we're using the value to see whether an error has occurred (!= 0), so we'd better not have a random val in there. value_ptr: There's no guarantee we're handed string lengths, so play it safe! Use prepared string lengths where possible for minimum speed gain, otherwise determine on the fly!
Diffstat (limited to 'sql/sql_plugin.cc')
-rw-r--r--sql/sql_plugin.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index b411d5e3095..bafc601d142 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -2066,7 +2066,7 @@ static int check_func_set(THD *thd, struct st_mysql_sys_var *var,
const char *strvalue= "NULL", *str;
TYPELIB *typelib;
ulonglong result;
- uint error_len;
+ uint error_len= 0; // init as only set on error
bool not_used;
int length;
@@ -2665,7 +2665,9 @@ uchar* sys_var_pluginvar::value_ptr(THD *thd, enum_var_type type,
{
if (!(value & mask))
continue;
- str.append(typelib->type_names[i], typelib->type_lengths[i]);
+ str.append(typelib->type_names[i], typelib->type_lengths
+ ? typelib->type_lengths[i]
+ : strlen(typelib->type_names[i]));
str.append(',');
}