[MDEV-12311] Insufficient check for argument validity in JSON functions Created: 2017-03-20  Updated: 2017-10-05  Resolved: 2017-10-05

Status: Closed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.2
Fix Version/s: 10.2.10

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
Sprint: 10.2.10

 Description   

Example is for JSON_LENGTH, probably other functions are similarly affected, please keep them consistent.

JSON_LENGTH does some check on argument validity:

10.2 (OK)

MariaDB [test]> select json_length('{{');
+-------------------+
| json_length('{{') |
+-------------------+
|              NULL |
+-------------------+
1 row in set, 1 warning (0.00 sec)
 
MariaDB [test]> show warnings;
+---------+------+---------------------------------------------------------------------------------+
| Level   | Code | Message                                                                         |
+---------+------+---------------------------------------------------------------------------------+
| Warning | 4038 | Syntax error in JSON text in argument 1 to function 'json_length' at position 2 |
+---------+------+---------------------------------------------------------------------------------+
1 row in set (0.00 sec)

But it does not notice obvious problems in the argument:

10.2 (not OK)

MariaDB [test]> select json_length('{}{');
+--------------------+
| json_length('{}{') |
+--------------------+
|                  0 |
+--------------------+
1 row in set (0.00 sec)

MySQL provides decent diagnostics:

MySQL 5.7

MySQL [test]> select json_length('{}{');
ERROR 3141 (22032): Invalid JSON text in argument 1 to function json_length: "The document root must not follow by other values." at position 2.



 Comments   
Comment by Alexey Botchkov [ 2017-10-05 ]

http://lists.askmonty.org/pipermail/commits/2017-October/011527.html

Generated at Thu Feb 08 07:56:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.