summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-08-19 22:42:56 +0400
committerAlexander Barkov <bar@mariadb.com>2019-08-20 05:28:14 +0400
commita7e2cd55ab3e8bc1d658c3b6ac11c7834783acd5 (patch)
tree2ba3d1c3a4be1ef5e8c5c8100b03e90d5c0c4290
parent457dc9d64d9f044760adbeca6facc813b754d43b (diff)
downloadmariadb-git-a7e2cd55ab3e8bc1d658c3b6ac11c7834783acd5.tar.gz
MDEV-19034 ASAN unknown-crash in get_date_time_separator with PAD_CHAR_TO_FULL_LENGTH
-rw-r--r--mysql-test/r/type_datetime.result11
-rw-r--r--mysql-test/t/type_datetime.test14
-rw-r--r--sql-common/my_time.c2
3 files changed, 26 insertions, 1 deletions
diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result
index 292c92422de..dcc7411a6f2 100644
--- a/mysql-test/r/type_datetime.result
+++ b/mysql-test/r/type_datetime.result
@@ -1156,5 +1156,16 @@ ExtractValue('foo','bar') i MIN(d)
3 1976-12-14 13:21:07
DROP TABLE t1;
#
+# MDEV-19034 ASAN unknown-crash in get_date_time_separator with PAD_CHAR_TO_FULL_LENGTH
+#
+SET SQL_MODE=DEFAULT;
+CREATE OR REPLACE TABLE t1 (a CHAR(11));
+CREATE OR REPLACE TABLE t2 (b DATETIME);
+INSERT INTO t1 VALUES ('2010-02-19') ;
+SET SQL_MODE= 'PAD_CHAR_TO_FULL_LENGTH';
+INSERT INTO t2 SELECT * FROM t1;
+DROP TABLE t1, t2;
+SET SQL_MODE=DEFAULT;
+#
# End of 10.1 tests
#
diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test
index 726510b74e8..3c5d1dbd62c 100644
--- a/mysql-test/t/type_datetime.test
+++ b/mysql-test/t/type_datetime.test
@@ -711,5 +711,19 @@ SELECT ExtractValue('foo','bar'), i, MIN(d) FROM t1 GROUP BY i;
DROP TABLE t1;
--echo #
+--echo # MDEV-19034 ASAN unknown-crash in get_date_time_separator with PAD_CHAR_TO_FULL_LENGTH
+--echo #
+
+SET SQL_MODE=DEFAULT;
+CREATE OR REPLACE TABLE t1 (a CHAR(11));
+CREATE OR REPLACE TABLE t2 (b DATETIME);
+INSERT INTO t1 VALUES ('2010-02-19') ;
+SET SQL_MODE= 'PAD_CHAR_TO_FULL_LENGTH';
+INSERT INTO t2 SELECT * FROM t1;
+DROP TABLE t1, t2;
+SET SQL_MODE=DEFAULT;
+
+
+--echo #
--echo # End of 10.1 tests
--echo #
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index 01b4d1fc2c9..5482b6dfa5c 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -184,7 +184,7 @@ static int get_date_time_separator(uint *number_of_fields, ulonglong flags,
do
{
s++;
- } while (my_isspace(&my_charset_latin1, *s));
+ } while (s < end && my_isspace(&my_charset_latin1, *s));
*str= s;
return 0;
}