Bug#15328 Segmentation fault occured if my.cnf is invalid for escape sequence

 - Check that length of value is longer than 1 before decrementing length by 2.
 - Backport from 5.0, make it possible to use my_print_defaults in tests
parent 274df0cc
...@@ -179,6 +179,7 @@ our $exe_mysqlshow; # Called from test case ...@@ -179,6 +179,7 @@ our $exe_mysqlshow; # Called from test case
our $exe_mysql_fix_system_tables; our $exe_mysql_fix_system_tables;
our $exe_mysqltest; our $exe_mysqltest;
our $exe_slave_mysqld; our $exe_slave_mysqld;
our $exe_my_print_defaults;
our $opt_bench= 0; our $opt_bench= 0;
our $opt_small_bench= 0; our $opt_small_bench= 0;
...@@ -893,6 +894,8 @@ sub executable_setup () { ...@@ -893,6 +894,8 @@ sub executable_setup () {
"$path_client_bindir/mysqld-max"); "$path_client_bindir/mysqld-max");
$path_language= mtr_path_exists("$glob_basedir/share/english/"); $path_language= mtr_path_exists("$glob_basedir/share/english/");
$path_charsetsdir= mtr_path_exists("$glob_basedir/share/charsets"); $path_charsetsdir= mtr_path_exists("$glob_basedir/share/charsets");
$exe_my_print_defaults=
mtr_exe_exists("$path_client_bindir/my_print_defaults");
} }
else else
{ {
...@@ -900,6 +903,8 @@ sub executable_setup () { ...@@ -900,6 +903,8 @@ sub executable_setup () {
$exe_mysqld= mtr_exe_exists ("$glob_basedir/sql/mysqld"); $exe_mysqld= mtr_exe_exists ("$glob_basedir/sql/mysqld");
$path_language= mtr_path_exists("$glob_basedir/sql/share/english/"); $path_language= mtr_path_exists("$glob_basedir/sql/share/english/");
$path_charsetsdir= mtr_path_exists("$glob_basedir/sql/share/charsets"); $path_charsetsdir= mtr_path_exists("$glob_basedir/sql/share/charsets");
$exe_my_print_defaults=
mtr_exe_exists("$glob_basedir/extra/my_print_defaults");
} }
if ( $glob_use_embedded_server ) if ( $glob_use_embedded_server )
...@@ -952,6 +957,8 @@ sub executable_setup () { ...@@ -952,6 +957,8 @@ sub executable_setup () {
$exe_mysql_fix_system_tables= $exe_mysql_fix_system_tables=
mtr_script_exists("$path_client_bindir/mysql_fix_privilege_tables", mtr_script_exists("$path_client_bindir/mysql_fix_privilege_tables",
"$glob_basedir/scripts/mysql_fix_privilege_tables"); "$glob_basedir/scripts/mysql_fix_privilege_tables");
$exe_my_print_defaults=
mtr_exe_exists("$path_client_bindir/my_print_defaults");
$path_language= mtr_path_exists("$glob_basedir/share/mysql/english/", $path_language= mtr_path_exists("$glob_basedir/share/mysql/english/",
"$glob_basedir/share/english/"); "$glob_basedir/share/english/");
...@@ -2303,6 +2310,7 @@ sub run_mysqltest ($) { ...@@ -2303,6 +2310,7 @@ sub run_mysqltest ($) {
$ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables; $ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables;
$ENV{'MYSQL_CLIENT_TEST'}= $cmdline_mysql_client_test; $ENV{'MYSQL_CLIENT_TEST'}= $cmdline_mysql_client_test;
$ENV{'CHARSETSDIR'}= $path_charsetsdir; $ENV{'CHARSETSDIR'}= $path_charsetsdir;
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= $exe_my_print_defaults;
$ENV{'NDB_STATUS_OK'}= $flag_ndb_status_ok; $ENV{'NDB_STATUS_OK'}= $flag_ndb_status_ok;
$ENV{'NDB_MGM'}= $exe_ndb_mgm; $ENV{'NDB_MGM'}= $exe_ndb_mgm;
......
...@@ -601,6 +601,7 @@ if [ x$SOURCE_DIST = x1 ] ; then ...@@ -601,6 +601,7 @@ if [ x$SOURCE_DIST = x1 ] ; then
CLIENT_BINDIR="$BASEDIR/client" CLIENT_BINDIR="$BASEDIR/client"
MYSQLADMIN="$CLIENT_BINDIR/mysqladmin" MYSQLADMIN="$CLIENT_BINDIR/mysqladmin"
WAIT_PID="$BASEDIR/extra/mysql_waitpid" WAIT_PID="$BASEDIR/extra/mysql_waitpid"
MYSQL_MY_PRINT_DEFAULTS="$BASEDIR/extra/my_print_defaults"
MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqlmanagerc" MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqlmanagerc"
MYSQL_MANAGER="$BASEDIR/tools/mysqlmanager" MYSQL_MANAGER="$BASEDIR/tools/mysqlmanager"
MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqlmanager-pwgen" MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqlmanager-pwgen"
...@@ -661,6 +662,7 @@ else ...@@ -661,6 +662,7 @@ else
MYSQL_BINLOG="$CLIENT_BINDIR/mysqlbinlog" MYSQL_BINLOG="$CLIENT_BINDIR/mysqlbinlog"
MYSQLADMIN="$CLIENT_BINDIR/mysqladmin" MYSQLADMIN="$CLIENT_BINDIR/mysqladmin"
WAIT_PID="$CLIENT_BINDIR/mysql_waitpid" WAIT_PID="$CLIENT_BINDIR/mysql_waitpid"
MYSQL_MY_PRINT_DEFAULTS="$CLIENT_BINDIR/my_print_defaults"
MYSQL_MANAGER="$CLIENT_BINDIR/mysqlmanager" MYSQL_MANAGER="$CLIENT_BINDIR/mysqlmanager"
MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqlmanagerc" MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqlmanagerc"
MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqlmanager-pwgen" MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqlmanager-pwgen"
...@@ -742,7 +744,7 @@ MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR $EXTRA_MYS ...@@ -742,7 +744,7 @@ MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR $EXTRA_MYS
MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose" MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose"
MYSQL="$MYSQL --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD" MYSQL="$MYSQL --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD"
export MYSQL MYSQL_DUMP MYSQL_IMPORT MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES export MYSQL MYSQL_DUMP MYSQL_IMPORT MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES
export CLIENT_BINDIR MYSQL_CLIENT_TEST CHARSETSDIR export CLIENT_BINDIR MYSQL_CLIENT_TEST CHARSETSDIR MYSQL_MY_PRINT_DEFAULTS
export NDB_TOOLS_DIR export NDB_TOOLS_DIR
export NDB_MGM export NDB_MGM
export NDB_BACKUP_DIR export NDB_BACKUP_DIR
......
...@@ -1503,3 +1503,4 @@ select * from t1; ...@@ -1503,3 +1503,4 @@ select * from t1;
a b a b
Osnabrck Kln Osnabrck Kln
drop table t1; drop table t1;
--fields-optionally-enclosed-by="
[mysqldump]
fields-optionally-enclosed-by="
...@@ -647,4 +647,12 @@ select * from t1; ...@@ -647,4 +647,12 @@ select * from t1;
select * from t1; select * from t1;
drop table t1; drop table t1;
#
# BUG#15328 Segmentation fault occured if my.cnf is invalid for escape sequence
#
--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQL_TEST_DIR/std_data/bug15328.cnf mysqldump
# End of 4.1 tests # End of 4.1 tests
...@@ -579,7 +579,9 @@ static int search_default_file_with_ext(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, ...@@ -579,7 +579,9 @@ static int search_default_file_with_ext(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
value_end=value; value_end=value;
/* remove quotes around argument */ /* remove quotes around argument */
if ((*value == '\"' || *value == '\'') && *value == value_end[-1]) if ((*value == '\"' || *value == '\'') && /* First char is quote */
(value + 1 < value_end ) && /* String is longer than 1 */
*value == value_end[-1] ) /* First char is equal to last char */
{ {
value++; value++;
value_end--; value_end--;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment