From: Date: October 5 2006 1:45am Subject: bk commit into 5.1 tree (jpipes:1.2323) BUG#21412 List-Archive: http://lists.mysql.com/commits/13098 X-Bug: 21412 Message-Id: <20061004234537.4E7DC470399@shakedown.mysql.com> Below is the list of changes that have just been committed into a local 5.1 repository of jpipes. When jpipes does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2006-10-04 19:45:31-04:00, jpipes@shakedown.(none) +3 -0 Bug #21412: mysql cmdline client allows backslashes as delimiter but can't recognize them Added checks in client/mysql.cc for get_one_option() and com_delimiter() to ensure a backslash could not be used in the delimiter string. client/mysql.cc@stripped, 2006-10-04 19:45:29-04:00, jpipes@shakedown.(none) +21 -2 Bug #21412: mysql cmdline client allows backslashes as delimiter but can't recognize them Added checks in get_one_option() and com_delimiter() to ensure a backslash could not be used in the delimiter string. mysql-test/r/mysql.result@stripped, 2006-10-04 19:45:29-04:00, jpipes@shakedown.(none) +4 -0 Added tests for regular delimiter and two series of backslash characters for the delimiter (should not be allowed). Test for Bug #21412 (mysql cmdline client allows backslash(es) as delimiter but can't recognize them mysql-test/t/mysql.test@stripped, 2006-10-04 19:45:29-04:00, jpipes@shakedown.(none) +18 -0 Bug #21412: mysql cmdline client allows backslashes as delimiter but can't recognize them Added checks in get_one_option() and com_delimiter() to ensure a backslash could not be used in the delimiter string. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: jpipes # Host: shakedown.(none) # Root: /home/jpipes/dev/mysql-5.1-new-maint --- 1.231/client/mysql.cc 2006-10-04 19:45:37 -04:00 +++ 1.232/client/mysql.cc 2006-10-04 19:45:37 -04:00 @@ -807,8 +807,19 @@ case OPT_DELIMITER: if (argument == disabled_my_option) strmov(delimiter, DEFAULT_DELIMITER); - else - strmake(delimiter, argument, sizeof(delimiter) - 1); + else + { + /* Don't allow backslash character in delimiter */ + if (strchr(argument, '\\')== NULL) + { + strmake(delimiter, argument, sizeof(delimiter) - 1); + } + else + { + put_info("DELIMITER cannot contain a backslash character", INFO_ERROR); + return 0; + } + } delimiter_length= (uint)strlen(delimiter); delimiter_str= delimiter; break; @@ -2996,6 +3007,14 @@ put_info("DELIMITER must be followed by a 'delimiter' character or string", INFO_ERROR); return 0; + } + else + { + if (strchr(tmp, '\\')!= NULL) + { + put_info("DELIMITER cannot contain a backslash character", INFO_ERROR); + return 0; + } } strmake(delimiter, tmp, sizeof(delimiter) - 1); delimiter_length= (int)strlen(delimiter); --- 1.17/mysql-test/r/mysql.result 2006-10-04 19:45:37 -04:00 +++ 1.18/mysql-test/r/mysql.result 2006-10-04 19:45:37 -04:00 @@ -139,4 +139,8 @@ \\ '; '; +1 +1 +ERROR at line 1: DELIMITER cannot contain a backslash character +ERROR at line 1: DELIMITER cannot contain a backslash character End of 5.0 tests --- 1.20/mysql-test/t/mysql.test 2006-10-04 19:45:37 -04:00 +++ 1.21/mysql-test/t/mysql.test 2006-10-04 19:45:37 -04:00 @@ -147,4 +147,22 @@ --exec echo "SELECT '\';';" >> $MYSQLTEST_VARDIR/tmp/bug20103.sql --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20103.sql 2>&1 +# +# Bug #21412: mysql cmdline client allows backslash(es) +# as delimiter but can't recognize them +# + +# This should work just fine... +--exec echo "DELIMITER /" > $MYSQLTEST_VARDIR/tmp/bug21412.sql +--exec echo "SELECT 1/" >> $MYSQLTEST_VARDIR/tmp/bug21412.sql +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1 + +# This should give an error... +--exec echo "DELIMITER \\" > $MYSQLTEST_VARDIR/tmp/bug21412.sql +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1 + +# As should this... +--exec echo "DELIMITER \\\\" > $MYSQLTEST_VARDIR/tmp/bug21412.sql +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1 + --echo End of 5.0 tests