Commit f4eac2de authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-16054 simple json functions flatline cpu on garbage input.

Incorrect char sentence should be handled properly.
parent fd378fc6
...@@ -760,3 +760,9 @@ t1 CREATE TABLE `t1` ( ...@@ -760,3 +760,9 @@ t1 CREATE TABLE `t1` (
`c2` varchar(38) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL `c2` varchar(38) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-16054 simple json functions flatline cpu on garbage input.
#
select json_array(1,uuid(),compress(5.140264e+307));
json_array(1,uuid(),compress(5.140264e+307))
NULL
...@@ -422,3 +422,10 @@ CREATE TABLE t1 AS SELECT ...@@ -422,3 +422,10 @@ CREATE TABLE t1 AS SELECT
JSON_QUOTE(_utf8'foo') AS c2; JSON_QUOTE(_utf8'foo') AS c2;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-16054 simple json functions flatline cpu on garbage input.
--echo #
select json_array(1,uuid(),compress(5.140264e+307));
...@@ -1645,6 +1645,8 @@ int json_escape(CHARSET_INFO *str_cs, ...@@ -1645,6 +1645,8 @@ int json_escape(CHARSET_INFO *str_cs,
return -1; return -1;
} }
} }
else /* c_len == 0, an illegal symbol. */
return -1;
} }
return (int)(json - json_start); return (int)(json - json_start);
......
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