Skip to content

Commit

Permalink
Fix buffer overrun
Browse files Browse the repository at this point in the history
  • Loading branch information
tohghua committed May 7, 2024
1 parent e4afa61 commit c69f00c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions mysys/ma_dyncol.c
Original file line number Diff line number Diff line change
Expand Up @@ -3848,13 +3848,13 @@ my_bool dynstr_append_json_quoted(DYNAMIC_STRING *str,
register char c= append[i];
if (unlikely(((uchar)c) <= 0x1F))
{
if (lim < 5)
if (lim < 6)
{
if (dynstr_realloc(str, additional))
return TRUE;
lim+= additional;
}
lim-= 5;
lim -= 6;
str->str[str->length++]= '\\';
str->str[str->length++]= 'u';
str->str[str->length++]= '0';
Expand All @@ -3865,17 +3865,18 @@ my_bool dynstr_append_json_quoted(DYNAMIC_STRING *str,
}
else
{
if (lim < 2)
{
if (dynstr_realloc(str, additional))
return TRUE;
lim += additional;
}
if (c == '"' || c == '\\')
{
if (!lim)
{
if (dynstr_realloc(str, additional))
return TRUE;
lim= additional;
}
lim--;
str->str[str->length++]= '\\';
}
lim--;
str->str[str->length++]= c;
}
}
Expand Down

0 comments on commit c69f00c

Please sign in to comment.