← Back to team overview

maria-developers team mailing list archive

bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2720)

 

#At lp:maria

 2720 knielsen@xxxxxxxxxxxxxxx	2009-08-27
      Fix parsing of invalid plugin enum option value.
      
      Previous patch to fix plugin enum option parsing on big-endian introduced another bug due
      to incorrect comparison of unsigned value. This would cause an incorrect value to be
      parsed as value 0.
      
      See also MySQL BUG#41010 and BUG#32034.
      added:
        mysql-test/r/plugin_load2.result
        mysql-test/t/plugin_load2-master.opt
        mysql-test/t/plugin_load2.test
      modified:
        mysql-test/valgrind.supp
        mysys/my_getopt.c

per-file messages:
  mysql-test/r/plugin_load2.result
    Add test case.
  mysql-test/t/plugin_load2-master.opt
    Add test case.
  mysql-test/t/plugin_load2.test
    Add test case.
  mysql-test/valgrind.supp
    Make dlclose() suppression catch also another possible call path, seen in new test case.
  mysys/my_getopt.c
    Fix incorrect comparison of unsigned value.
=== added file 'mysql-test/r/plugin_load2.result'
--- a/mysql-test/r/plugin_load2.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/plugin_load2.result	2009-08-27 09:42:25 +0000
@@ -0,0 +1,2 @@
+SELECT @@global.example_enum_var = 'e2';
+ERROR HY000: Unknown system variable 'example_enum_var'

=== added file 'mysql-test/t/plugin_load2-master.opt'
--- a/mysql-test/t/plugin_load2-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/plugin_load2-master.opt	2009-08-27 09:42:25 +0000
@@ -0,0 +1,3 @@
+$EXAMPLE_PLUGIN_OPT
+"--plugin-load=;EXAMPLE=ha_example.so;"
+--loose-plugin-example-enum-var=nonexistientvalue

=== added file 'mysql-test/t/plugin_load2.test'
--- a/mysql-test/t/plugin_load2.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/plugin_load2.test	2009-08-27 09:42:25 +0000
@@ -0,0 +1,12 @@
+--source include/have_example_plugin.inc
+
+# Test for bug in parsing plugin enum option.
+# The bug was that the error from parsing a non-existent value was not properly
+# handled, so the variable was assigned some arbitrary wrong value.
+#
+# We test this by passing --loose-plugin-example-enum-var=nonexistientvalue in
+# the .opt file of the test case, and check that the variable is not wrongly
+# set to a value in this case.
+
+--error 1193
+SELECT @@global.example_enum_var = 'e2';

=== modified file 'mysql-test/valgrind.supp'
--- a/mysql-test/valgrind.supp	2009-08-05 07:21:37 +0000
+++ b/mysql-test/valgrind.supp	2009-08-27 09:42:25 +0000
@@ -387,6 +387,12 @@
    fun:plugin_dl_del(st_mysql_lex_string const*)
 }
 
+#
+# Glibc _dl_close_worker() re-allocates a scope data structure, and frees the
+# old one. This isn't a leak, but generates "still reachable" warnings, as
+# there is no global destructor code to do a final free() at exit().
+#
+
 {
    dlclose memory loss from plugin variant 2
    Memcheck:Leak
@@ -397,7 +403,6 @@
    fun:_dlerror_run
    fun:dlclose
    fun:_Z15free_plugin_memP12st_plugin_dl
-   fun:_Z13plugin_dl_delPK19st_mysql_lex_string
 }
 
 {
@@ -411,7 +416,6 @@
    fun:_dlerror_run
    fun:dlclose
    fun:_Z15free_plugin_memP12st_plugin_dl
-   fun:_Z13plugin_dl_delPK19st_mysql_lex_string
 }
 
 {
@@ -424,7 +428,6 @@
    obj:/lib*/libdl-*.so
    fun:dlclose
    fun:_ZL15free_plugin_memP12st_plugin_dl
-   fun:_ZL13plugin_dl_delPK19st_mysql_lex_string
 }
 
 {
@@ -452,7 +455,6 @@
    fun:_dlerror_run
    fun:dlclose
    fun:_ZL15free_plugin_memP12st_plugin_dl
-   fun:_ZL13plugin_dl_delPK19st_mysql_lex_string
 }
 
 {
@@ -466,7 +468,6 @@
    fun:_dlerror_run
    fun:dlclose
    fun:_ZL15free_plugin_memP12st_plugin_dl
-   fun:_ZL13plugin_dl_delPK19st_mysql_lex_string
 }
 
 {

=== modified file 'mysys/my_getopt.c'
--- a/mysys/my_getopt.c	2009-05-20 15:34:34 +0000
+++ b/mysys/my_getopt.c	2009-08-27 09:42:25 +0000
@@ -603,6 +603,7 @@ static int setval(const struct my_option
 		  my_bool set_maximum_value)
 {
   int err= 0;
+  int pos;
 
   if (value && argument)
   {
@@ -647,7 +648,9 @@ static int setval(const struct my_option
 	return EXIT_OUT_OF_MEMORY;
       break;
     case GET_ENUM:
-      if (((*(ulong *)result_pos)= find_type(argument, opts->typelib, 2) - 1) < 0)
+      pos = find_type(argument, opts->typelib, 2) - 1;
+      (*(ulong *)result_pos)= pos;
+      if (pos < 0)
         return EXIT_ARGUMENT_INVALID;
       break;
     case GET_SET:




Follow ups