[Commits] 917f636563e: MDEV-27203: Valgrind / MSAN errors in Histogram_json_hb::parse_bucket
revision-id: 917f636563ea2e300c7f7f9ab0f240749525da51 (mariadb-10.6.1-329-g917f636563e) parent(s): da3231a86f90cdd1387b4d36f9b6a4b5df9ae5fc author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2021-12-13 22:54:33 +0300 message: MDEV-27203: Valgrind / MSAN errors in Histogram_json_hb::parse_bucket In read_bucket_endpoint(), handle all possible parser states. --- mysql-test/main/statistics_json.result | 2 +- sql/opt_histogram_json.cc | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result index 50a79d8f834..7373da0570b 100644 --- a/mysql-test/main/statistics_json.result +++ b/mysql-test/main/statistics_json.result @@ -4688,7 +4688,7 @@ explain select * from t1_json limit 1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 Warnings: -Warning 4186 Failed to parse histogram for table test.t1_json: "size" element not present at offset 28. +Warning 4186 Failed to parse histogram for table test.t1_json: String or number expected at offset 27. UPDATE mysql.column_stats SET histogram='{"histogram_hb":[{"start":"aaa", "size":"not-an-integer"}]}' WHERE table_name='t1_json'; diff --git a/sql/opt_histogram_json.cc b/sql/opt_histogram_json.cc index 5d92c9535a4..d65bb225477 100644 --- a/sql/opt_histogram_json.cc +++ b/sql/opt_histogram_json.cc @@ -480,6 +480,13 @@ bool read_bucket_endpoint(json_engine_t *je, Field *field, String *out, if (json_read_value(je)) return true; + if (je->value_type != JSON_VALUE_STRING && + je->value_type != JSON_VALUE_NUMBER) + { + *err= "String or number expected"; + return true; + } + const char* je_value= (const char*)je->value; if (je->value_type == JSON_VALUE_STRING && je->value_escaped) {
participants (1)
-
psergey