Skip to content

Commit

Permalink
unescape: fix overflow on unescaping string (oss-fuzz 22132)
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <eduardo@treasure-data.com>
  • Loading branch information
edsiper committed May 11, 2020
1 parent 77cb629 commit 0c222db
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/flb_unescape.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,18 @@ int flb_unescape_string_utf8(const char *in_buf, int sz, char *out_buf)
{
uint32_t ch;
char temp[4];
const char *end;
const char *next;

int count_out = 0;
int count_in = 0;
int esc_in = 0;
int esc_out = 0;

while (*in_buf && count_in < sz) {
end = in_buf + sz;
while (in_buf < end && *in_buf && count_in < sz) {
next = in_buf + 1;

if (*in_buf == '\\') {
if (next < end && *in_buf == '\\') {
esc_in = 2;
switch (*next) {
case '"':
Expand Down

0 comments on commit 0c222db

Please sign in to comment.