From 71c896c2bf806c93a7685065af2943ab37678f3e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 31 Jul 2006 14:22:32 +0200 Subject: [PATCH] Bug#21042 mysql client segfaults on importing a mysqldump export - Use strmake, that will both protect the buffer and make sure it's terminated by a zero - Add test case client/mysql.cc: Use strmake instead of strxnmov as that function will make sure the string is terminated by 0 mysql-test/r/mysql.result: Update test result mysql-test/t/mysql.test: Add test case --- client/mysql.cc | 2 +- mysql-test/r/mysql.result | 1 + mysql-test/t/mysql.test | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/client/mysql.cc b/client/mysql.cc index 5c0b5ce04fe..25faf91b25d 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2858,7 +2858,7 @@ com_connect(String *buffer, char *line) bzero(buff, sizeof(buff)); if (buffer) { - strxnmov(buff, sizeof(buff), line, NullS); + strmake(buff, line, sizeof(buff)); tmp= get_arg(buff, 0); if (tmp && *tmp) { diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index 164ee4d50ac..55ed2a4868b 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -114,4 +114,5 @@ a int(11) YES NULL b varchar(255) YES NULL c int(11) YES NULL drop table t1; +ERROR 1049 (42000) at line 1: Unknown database 'verylongdatabasenamethatshouldblowthe256byteslongbufferincom_con' End of 5.0 tests diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index cfc47a5fbd5..10c07c931ab 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -86,6 +86,12 @@ create table t1(a int, b varchar(255), c int); --exec $MYSQL test -e "desc t1\g" drop table t1; +# +# Bug#21042 mysql client segfaults on importing a mysqldump export +# +--error 1 +--exec $MYSQL test -e "connect verylongdatabasenamethatshouldblowthe256byteslongbufferincom_connectfunctionxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxendcccccccdxxxxxxxxxxxxxxxxxkskskskskkskskskskskskskskskskkskskskskkskskskskskskskskskend" 2>&1 + --echo End of 5.0 tests