Skip to content

Commit a7a6c6e

Browse files
author
holyfoot/[email protected]/hfmain.(none)
committed
Bug #30955 geomfromtext() crasher.
end-of-line check missed in Gis_read_stream::get_next_word, what can lead to crashes (expecially with NULL strings). End-of-line check added
1 parent da04109 commit a7a6c6e

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

mysql-test/r/gis.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,4 +724,10 @@ SELECT * FROM t1;
724724
a
725725
NULL
726726
DROP TABLE t1;
727+
CREATE TABLE `t1` ( `col9` set('a'), `col89` date);
728+
INSERT INTO `t1` VALUES ('','0000-00-00');
729+
select geomfromtext(col9,col89) as a from t1;
730+
a
731+
NULL
732+
DROP TABLE t1;
727733
End of 4.1 tests

mysql-test/t/gis.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,4 +419,12 @@ INSERT INTO t1 VALUES (NULL);
419419
SELECT * FROM t1;
420420
DROP TABLE t1;
421421

422+
#
423+
# Bug #30955 geomfromtext() crasher
424+
#
425+
CREATE TABLE `t1` ( `col9` set('a'), `col89` date);
426+
INSERT INTO `t1` VALUES ('','0000-00-00');
427+
select geomfromtext(col9,col89) as a from t1;
428+
DROP TABLE t1;
429+
422430
--echo End of 4.1 tests

sql/gstream.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bool Gis_read_stream::get_next_word(LEX_STRING *res)
4545
skip_space();
4646
res->str= (char*) m_cur;
4747
/* The following will also test for \0 */
48-
if (!my_isvar_start(&my_charset_bin, *m_cur))
48+
if ((m_cur >= m_limit) || !my_isvar_start(&my_charset_bin, *m_cur))
4949
return 1;
5050

5151
/*

0 commit comments

Comments
 (0)