Bug#20894 Reproducible MySQL client segmentation fault

 - Add two null bytes in  "buff" variable allowing us to call
   get_arg two times also for strings longer than sizeof(buff) 
parent 6665d67e
......@@ -2934,7 +2934,11 @@ com_connect(String *buffer, char *line)
bzero(buff, sizeof(buff));
if (buffer)
{
strmake(buff, line, sizeof(buff) - 1);
/*
Two null bytes are needed in the end of buff to allow
get_arg to find end of string the second time it's called.
*/
strmake(buff, line, sizeof(buff)-2);
tmp= get_arg(buff, 0);
if (tmp && *tmp)
{
......
......@@ -162,4 +162,21 @@ select count(*) from t17583;
count(*)
1280
drop table t17583;
Test connect without db- or host-name => reconnect
Test connect with dbname only => new dbname, old hostname
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'connecttest' at line 1
Test connect with _invalid_ dbname only => new invalid dbname, old hostname
ERROR 1049 (42000) at line 1: Unknown database 'invalid'
ERROR 1049 (42000) at line 1: Unknown database 'invalid'
Test connect with dbname + hostname
Test connect with dbname + _invalid_ hostname
ERROR 2005 (HY000) at line 1: Unknown MySQL server host 'invalid_hostname' (errno)
ERROR 2005 (HY000) at line 1: Unknown MySQL server host 'invalid_hostname' (errno)
The commands reported in the bug report
ERROR 2005 (HY000) at line 1: Unknown MySQL server host 'cyril has found a bug :)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' (errno)
ERROR 2005 (HY000) at line 1: Unknown MySQL server host 'cyril has found a bug :)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' (errno)
Too long dbname
ERROR 1049 (42000) at line 1: Unknown database 'test_really_long_dbnameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
Too long hostname
ERROR 2005 (HY000) at line 1: Unknown MySQL server host 'cyrils_superlonghostnameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' (errno)
End of 5.0 tests
......@@ -170,4 +170,57 @@ select count(*) from t17583;
--exec echo "select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; " |$MYSQL test >&-
drop table t17583;
#
# Bug#20984: Reproducible MySQL client segmentation fault
# + additional tests for the "com_connect" function in mysql
#
#
--echo Test connect without db- or host-name => reconnect
--exec $MYSQL test -e "\r" 2>&1
--exec $MYSQL test -e "connect" 2>&1
--echo Test connect with dbname only => new dbname, old hostname
--exec $MYSQL test -e "\r test" 2>&1
--exec $MYSQL test -e "connect test" 2>&1
--exec $MYSQL test -e "\rtest" 2>&1
--error 1
--exec $MYSQL test -e "connecttest" 2>&1
--echo Test connect with _invalid_ dbname only => new invalid dbname, old hostname
--error 1
--exec $MYSQL test -e "\r invalid" 2>&1
--error 1
--exec $MYSQL test -e "connect invalid" 2>&1
--echo Test connect with dbname + hostname
--exec $MYSQL test -e "\r test localhost" 2>&1
--exec $MYSQL test -e "connect test localhost" 2>&1
--echo Test connect with dbname + _invalid_ hostname
# Mask the errno of the error message
--replace_regex /\([0-9]*\)/(errno)/
--error 1
--exec $MYSQL test -e "\r test invalid_hostname" 2>&1
--replace_regex /\([0-9]*\)/(errno)/
--error 1
--exec $MYSQL test -e "connect test invalid_hostname" 2>&1
--echo The commands reported in the bug report
--replace_regex /\([0-9]*\)/(errno)/
--error 1
--exec $MYSQL test -e "\r\r\n\r\n cyril\ has\ found\ a\ bug\ :)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 2>&1
--replace_regex /\([0-9]*\)/(errno)/
--error 1
--exec echo '\r\r\n\r\n cyril\ has\ found\ a\ bug\ :)XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | $MYSQL 2>&1
--echo Too long dbname
--error 1
--exec echo '\r test_really_long_dbnameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX localhost' | $MYSQL 2>&1
--echo Too long hostname
--replace_regex /\([0-9]*\)/(errno)/
--error 1
--exec echo '\r test cyrils_superlonghostnameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | $MYSQL 2>&1
--echo End of 5.0 tests
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