List:Commits« Previous MessageNext Message »
From:Mats Kindahl Date:November 27 2010 8:21pm
Subject:bzr commit into mysql-trunk-bugfixing branch (mats.kindahl:3388) Bug#58455
View as plain text  
#At file:///home/bzr/mkindahl/testing-trunk-bugfixing/ based on revid:sergey.glukhov@stripped

 3388 Mats Kindahl	2010-11-27
      Bug #58455
      Starting mysqld with defaults file without
      extension cause segmentation fault
      
      Bug occurs because fn_expand calls fn_format
      with NULL as ext.
      
      Patch solve this problem by using an empty
      string as extension, and adding assertions
      to fn_format that correct arguments are passed.
      
      It also add a test tests several variations of
      using non-existing defaults files.

    added:
      mysql-test/r/mysqld--defaults-file.result
      mysql-test/t/mysqld--defaults-file.test
    modified:
      mysys/default.c
      mysys/mf_format.c
=== added file 'mysql-test/r/mysqld--defaults-file.result'
--- a/mysql-test/r/mysqld--defaults-file.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/mysqld--defaults-file.result	2010-11-27 20:21:16 +0000
@@ -0,0 +1,12 @@
+Could not open required defaults file: /path/with/no/extension
+Fatal error in defaults handling. Program aborted
+Could not open required defaults file: /path/with.ext
+Fatal error in defaults handling. Program aborted
+Could not open required defaults file: MYSQL_TEST_DIR/relative/path/with.ext
+Fatal error in defaults handling. Program aborted
+Could not open required defaults file: MYSQL_TEST_DIR/relative/path/without/extension
+Fatal error in defaults handling. Program aborted
+Could not open required defaults file: MYSQL_TEST_DIR/with.ext
+Fatal error in defaults handling. Program aborted
+Could not open required defaults file: MYSQL_TEST_DIR/no_extension
+Fatal error in defaults handling. Program aborted

=== added file 'mysql-test/t/mysqld--defaults-file.test'
--- a/mysql-test/t/mysqld--defaults-file.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/mysqld--defaults-file.test	2010-11-27 20:21:16 +0000
@@ -0,0 +1,46 @@
+# BUG#58455
+# Starting mysqld with defaults file without extension cause
+# segmentation fault
+
+source include/not_embedded.inc;
+
+# We need to use a plain "mysqld" without any other options to trigger
+# the bug. In particular, it seems that passing --bootstrap does not
+# trigger the bug. To do that, we extract the "command name" from the
+# MYSQLD_BOOTSTRAP_CMD variable and store that in a file, which we
+# then load into the test case.
+
+perl;
+  my ($mysqld)= split " ", $ENV{MYSQLD_BOOTSTRAP_CMD};
+  open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/mysqld.inc") or die;
+  print FILE "let \$MYSQLD= $mysqld;\n";
+  close FILE;
+EOF
+
+source $MYSQL_TMP_DIR/mysqld.inc;
+
+# All these tests refer to configuration files that do not exist
+
+--error 1
+exec $MYSQLD --defaults-file=/path/with/no/extension --print-defaults 2>&1;
+
+--error 1
+exec $MYSQLD --defaults-file=/path/with.ext --print-defaults 2>&1;
+
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+--error 1
+exec $MYSQLD --defaults-file=relative/path/with.ext --print-defaults 2>&1;
+
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+--error 1
+exec $MYSQLD --defaults-file=relative/path/without/extension --print-defaults 2>&1;
+
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+--error 1
+exec $MYSQLD --defaults-file=with.ext --print-defaults 2>&1;
+
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+--error 1
+exec $MYSQLD --defaults-file=no_extension --print-defaults 2>&1;
+
+remove_file $MYSQL_TMP_DIR/mysqld.inc;

=== modified file 'mysys/default.c'
--- a/mysys/default.c	2010-11-16 11:07:17 +0000
+++ b/mysys/default.c	2010-11-27 20:21:16 +0000
@@ -165,7 +165,7 @@ fn_expand(const char *filename, char *re
   if (my_getwd(dir, sizeof(dir), MYF(0)))
     DBUG_RETURN(3);
   DBUG_PRINT("debug", ("dir: %s", dir));
-  if (fn_format(result_buf, filename, dir, NULL, flags) == NULL)
+  if (fn_format(result_buf, filename, dir, "", flags) == NULL)
     DBUG_RETURN(2);
   DBUG_PRINT("return", ("result: %s", result_buf));
   DBUG_RETURN(0);

=== modified file 'mysys/mf_format.c'
--- a/mysys/mf_format.c	2009-04-19 01:21:33 +0000
+++ b/mysys/mf_format.c	2010-11-27 20:21:16 +0000
@@ -31,6 +31,8 @@ char * fn_format(char * to, const char *
   reg1 size_t length;
   size_t dev_length;
   DBUG_ENTER("fn_format");
+  DBUG_ASSERT(name != NULL);
+  DBUG_ASSERT(extension != NULL);
   DBUG_PRINT("enter",("name: %s  dir: %s  extension: %s  flag: %d",
 		       name,dir,extension,flag));
 


Attachment: [text/bzr-bundle] bzr/mats.kindahl@oracle.com-20101127202116-nkr3xlq5q33s8gfe.bundle
Thread
bzr commit into mysql-trunk-bugfixing branch (mats.kindahl:3388) Bug#58455Mats Kindahl27 Nov