func_json: Fix crashes for some types

This commit fixes crashes in JSON_DECODE() for types null, true, false
and real numbers.

In addition it ensures that a path is not deeper than 32 levels.

Also allow root object to be an array.

Add unit tests for above cases.

(cherry picked from commit e6d5b8d8cf)
This commit is contained in:
Bastian Triller
2023-09-21 08:24:37 +02:00
committed by Asterisk Development Team
parent c47a386cf2
commit 7a1208410a
3 changed files with 77 additions and 22 deletions

View File

@@ -268,6 +268,22 @@ struct ast_json *ast_json_boolean(int value);
*/
struct ast_json *ast_json_null(void);
/*!
* \brief Check if \a value is JSON array.
* \since 12.0.0
* \retval True (non-zero) if \a value == \ref ast_json_array().
* \retval False (zero) otherwise..
*/
int ast_json_is_array(const struct ast_json *value);
/*!
* \brief Check if \a value is JSON object.
* \since 12.0.0
* \retval True (non-zero) if \a value == \ref ast_json_object().
* \retval False (zero) otherwise..
*/
int ast_json_is_object(const struct ast_json *value);
/*!
* \brief Check if \a value is JSON true.
* \since 12.0.0