diff options
author | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2023-04-17 17:51:34 +0530 |
---|---|---|
committer | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2023-04-26 15:15:47 +0530 |
commit | 7321c71aa187ac55a248e68142df5606249a556e (patch) | |
tree | 9dbb584bc5a111ec2cbb5744368e5ef73b59d678 /mysql-test/main | |
parent | 4b67ff3b256a78994cb23dc4aa2ba531bbb06070 (diff) | |
download | mariadb-git-7321c71aa187ac55a248e68142df5606249a556e.tar.gz |
MDEV-31032: UBSAN|downcast of address X which does not point to an
object of type 'Item_string' in sql/json_schema.cc
Analysis: make_string_literal() returns pointer of type
Item_basic_constant which is converted to pointer of type Item_string. Now,
Item_string is base class of Item_basic_constant, so the error about
downcasting.
Fix: using constructor of Item_string type directly instead of
downcasting would be more appropriate.
Diffstat (limited to 'mysql-test/main')
-rw-r--r-- | mysql-test/main/func_json.result | 19 | ||||
-rw-r--r-- | mysql-test/main/func_json.test | 20 |
2 files changed, 39 insertions, 0 deletions
diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index ec70e8b47bf..24581926040 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -4649,4 +4649,23 @@ JSON_SCHEMA_VALID(@schema, '9007900000000060') SELECT JSON_SCHEMA_VALID(@schema, '9007900000000061'); JSON_SCHEMA_VALID(@schema, '9007900000000061') 0 +# +# MDEV-31032: UBSAN|downcast of address X which does not point to an object of type +# Item_string' in sql/json_schema.cc +# +SET @old_sql_mode= @@sql_mode; +SET @schema='{ "type":"object","patternProperties": { "^I_": {"type":"number"},"^S_" : {"type":"string"} } }'; +SET SESSION sql_mode='empty_string_is_null'; +SELECT JSON_SCHEMA_VALID (@schema,'{"key1":"val0","key2":0,"I_int":0,"S_":"abc","prop0":"str0"}'); +JSON_SCHEMA_VALID (@schema,'{"key1":"val0","key2":0,"I_int":0,"S_":"abc","prop0":"str0"}') +1 +SET @@sql_mode= @old_sql_mode; +SET @property_names='{ "PropertyNames":{ "pattern": "^I_" } }'; +SET GLOBAL sql_mode=17179869183; +SET @@sql_mode=DEFAULT; +SELECT JSON_SCHEMA_VALID(@property_names, '{"I_int1":3, "I_ob1":{"key1":"val1"}}'); +JSON_SCHEMA_VALID(@property_names, '{"I_int1":3, "I_ob1":{"key1":"val1"}}') +1 +SET @@sql_mode= @old_sql_mode; +set global sql_mode=default; # End of 11.1 test diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index d5631c1578c..d0588655dff 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -3543,5 +3543,25 @@ SELECT JSON_SCHEMA_VALID(@schema, '9007900000000001'); SELECT JSON_SCHEMA_VALID(@schema, '9007900000000060'); SELECT JSON_SCHEMA_VALID(@schema, '9007900000000061'); +--echo # +--echo # MDEV-31032: UBSAN|downcast of address X which does not point to an object of type +--echo # Item_string' in sql/json_schema.cc +--echo # + +SET @old_sql_mode= @@sql_mode; + +SET @schema='{ "type":"object","patternProperties": { "^I_": {"type":"number"},"^S_" : {"type":"string"} } }'; +SET SESSION sql_mode='empty_string_is_null'; +SELECT JSON_SCHEMA_VALID (@schema,'{"key1":"val0","key2":0,"I_int":0,"S_":"abc","prop0":"str0"}'); + +SET @@sql_mode= @old_sql_mode; + +SET @property_names='{ "PropertyNames":{ "pattern": "^I_" } }'; +SET GLOBAL sql_mode=17179869183; +SET @@sql_mode=DEFAULT; +SELECT JSON_SCHEMA_VALID(@property_names, '{"I_int1":3, "I_ob1":{"key1":"val1"}}'); + +SET @@sql_mode= @old_sql_mode; +set global sql_mode=default; --echo # End of 11.1 test |