mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-26724 Endless loop in json_escape_to_string upon ... empty string
Part#3: - make json_escape() return different errors on conversion error and on out-of-space condition. - Make histogram code handle conversion errors.
This commit is contained in:
@@ -382,6 +382,9 @@ int json_find_paths_first(json_engine_t *je, json_find_paths_t *state,
|
||||
int json_find_paths_next(json_engine_t *je, json_find_paths_t *state);
|
||||
|
||||
|
||||
#define JSON_ERROR_OUT_OF_SPACE (-1)
|
||||
#define JSON_ERROR_ILLEGAL_SYMBOL (-2)
|
||||
|
||||
/*
|
||||
Converst JSON string constant into ordinary string constant
|
||||
which can involve unpacking json escapes and changing character set.
|
||||
@@ -394,10 +397,13 @@ int json_unescape(CHARSET_INFO *json_cs,
|
||||
uchar *res, uchar *res_end);
|
||||
|
||||
/*
|
||||
Converst ordinary string constant into JSON string constant.
|
||||
which can involve appropriate escaping and changing character set.
|
||||
Returns negative integer in the case of an error,
|
||||
the length of the result otherwise.
|
||||
Convert a string constant into JSON string constant.
|
||||
This can involve appropriate escaping and changing the character set.
|
||||
Returns the length of the result on success,
|
||||
on error returns a negative error code.
|
||||
Some error codes:
|
||||
JSON_ERROR_OUT_OF_SPACE Not enough space in the provided buffer
|
||||
JSON_ERROR_ILLEGAL_SYMBOL Source symbol cannot be represented in JSON
|
||||
*/
|
||||
int json_escape(CHARSET_INFO *str_cs, const uchar *str, const uchar *str_end,
|
||||
CHARSET_INFO *json_cs, uchar *json, uchar *json_end);
|
||||
|
Reference in New Issue
Block a user