mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-28762: recursive call of some json functions without stack control
This commit is a fixup for MDEV-28762 Analysis: Some recursive json functions dont check for stack control Fix: Add check_stack_overrun(). The last argument is NULL because it is not used
This commit is contained in:
@@ -4,8 +4,8 @@
|
|||||||
#
|
#
|
||||||
SET @saved_dbug = @@debug_dbug;
|
SET @saved_dbug = @@debug_dbug;
|
||||||
SET debug_dbug='+d,json_check_min_stack_requirement';
|
SET debug_dbug='+d,json_check_min_stack_requirement';
|
||||||
SET @json1= '{"key1":"val1"}';
|
SET @json1= '{"key1":{"key1":"val1"}}';
|
||||||
SET @json2= '{"key1":"val1"}';
|
SET @json2= '{"key1":{"key1":"val1"}}';
|
||||||
SELECT JSON_CONTAINS(@json1, @json2);
|
SELECT JSON_CONTAINS(@json1, @json2);
|
||||||
ERROR HY000: Thread stack overrun: 'used bytes' used of a 'available' byte stack, and 'X' bytes needed. Use 'mysqld --thread_stack=#' to specify a bigger stack
|
ERROR HY000: Thread stack overrun: 'used bytes' used of a 'available' byte stack, and 'X' bytes needed. Use 'mysqld --thread_stack=#' to specify a bigger stack
|
||||||
SET debug_dbug='+d,temp';
|
SET debug_dbug='+d,temp';
|
||||||
|
@@ -9,8 +9,8 @@
|
|||||||
SET @saved_dbug = @@debug_dbug;
|
SET @saved_dbug = @@debug_dbug;
|
||||||
SET debug_dbug='+d,json_check_min_stack_requirement';
|
SET debug_dbug='+d,json_check_min_stack_requirement';
|
||||||
|
|
||||||
SET @json1= '{"key1":"val1"}';
|
SET @json1= '{"key1":{"key1":"val1"}}';
|
||||||
SET @json2= '{"key1":"val1"}';
|
SET @json2= '{"key1":{"key1":"val1"}}';
|
||||||
|
|
||||||
--replace_regex /overrun: [0-9]* bytes used of a [0-9]* byte stack, and [0-9]* bytes needed/overrun: 'used bytes' used of a 'available' byte stack, and 'X' bytes needed/
|
--replace_regex /overrun: [0-9]* bytes used of a [0-9]* byte stack, and [0-9]* bytes needed/overrun: 'used bytes' used of a 'available' byte stack, and 'X' bytes needed/
|
||||||
--error ER_STACK_OVERRUN_NEED_MORE
|
--error ER_STACK_OVERRUN_NEED_MORE
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "sql_parse.h" // For check_stack_overrun
|
#include "sql_parse.h" // For check_stack_overrun
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Compare ASCII string against the string with the specified
|
Compare ASCII string against the string with the specified
|
||||||
character set.
|
character set.
|
||||||
@@ -136,9 +135,11 @@ int json_path_parts_compare(
|
|||||||
{
|
{
|
||||||
int res, res2;
|
int res, res2;
|
||||||
|
|
||||||
|
long arbitrary_var;
|
||||||
|
long stack_used_up= (available_stack_size(current_thd->thread_stack, &arbitrary_var));
|
||||||
DBUG_EXECUTE_IF("json_check_min_stack_requirement",
|
DBUG_EXECUTE_IF("json_check_min_stack_requirement",
|
||||||
{alloca(my_thread_stack_size-(STACK_MIN_SIZE));});
|
{alloca(my_thread_stack_size-stack_used_up-STACK_MIN_SIZE);});
|
||||||
if (check_stack_overrun(current_thd, STACK_MIN_SIZE, NULL))
|
if (check_stack_overrun(current_thd, STACK_MIN_SIZE , NULL))
|
||||||
return 1;
|
return 1;
|
||||||
while (a <= a_end)
|
while (a <= a_end)
|
||||||
{
|
{
|
||||||
@@ -1135,6 +1136,12 @@ static int check_contains(json_engine_t *js, json_engine_t *value)
|
|||||||
{
|
{
|
||||||
json_engine_t loc_js;
|
json_engine_t loc_js;
|
||||||
bool set_js;
|
bool set_js;
|
||||||
|
long arbitrary_var;
|
||||||
|
long stack_used_up= (available_stack_size(current_thd->thread_stack, &arbitrary_var));
|
||||||
|
DBUG_EXECUTE_IF("json_check_min_stack_requirement",
|
||||||
|
{alloca(my_thread_stack_size-stack_used_up-STACK_MIN_SIZE);});
|
||||||
|
if (check_stack_overrun(current_thd, STACK_MIN_SIZE , NULL))
|
||||||
|
return 1;
|
||||||
|
|
||||||
DBUG_EXECUTE_IF("json_check_min_stack_requirement",
|
DBUG_EXECUTE_IF("json_check_min_stack_requirement",
|
||||||
{alloca(my_thread_stack_size-(STACK_MIN_SIZE));});
|
{alloca(my_thread_stack_size-(STACK_MIN_SIZE));});
|
||||||
@@ -2030,9 +2037,11 @@ err_return:
|
|||||||
static int do_merge(String *str, json_engine_t *je1, json_engine_t *je2)
|
static int do_merge(String *str, json_engine_t *je1, json_engine_t *je2)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
long arbitrary_var;
|
||||||
|
long stack_used_up= (available_stack_size(current_thd->thread_stack, &arbitrary_var));
|
||||||
DBUG_EXECUTE_IF("json_check_min_stack_requirement",
|
DBUG_EXECUTE_IF("json_check_min_stack_requirement",
|
||||||
{alloca(my_thread_stack_size-(STACK_MIN_SIZE));});
|
{alloca(my_thread_stack_size-stack_used_up-STACK_MIN_SIZE);});
|
||||||
if (check_stack_overrun(current_thd, STACK_MIN_SIZE, NULL))
|
if (check_stack_overrun(current_thd, STACK_MIN_SIZE , NULL))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (json_read_value(je1) || json_read_value(je2))
|
if (json_read_value(je1) || json_read_value(je2))
|
||||||
@@ -2367,9 +2376,11 @@ static int copy_value_patch(String *str, json_engine_t *je)
|
|||||||
static int do_merge_patch(String *str, json_engine_t *je1, json_engine_t *je2,
|
static int do_merge_patch(String *str, json_engine_t *je1, json_engine_t *je2,
|
||||||
bool *empty_result)
|
bool *empty_result)
|
||||||
{
|
{
|
||||||
|
long arbitrary_var;
|
||||||
|
long stack_used_up= (available_stack_size(current_thd->thread_stack, &arbitrary_var));
|
||||||
DBUG_EXECUTE_IF("json_check_min_stack_requirement",
|
DBUG_EXECUTE_IF("json_check_min_stack_requirement",
|
||||||
{alloca(my_thread_stack_size-(STACK_MIN_SIZE));});
|
{alloca(my_thread_stack_size-stack_used_up-STACK_MIN_SIZE);});
|
||||||
if (check_stack_overrun(current_thd, STACK_MIN_SIZE, NULL))
|
if (check_stack_overrun(current_thd, STACK_MIN_SIZE , NULL))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (json_read_value(je1) || json_read_value(je2))
|
if (json_read_value(je1) || json_read_value(je2))
|
||||||
|
Reference in New Issue
Block a user