Skip to content

Commit

Permalink
Fix read past end of buffer
Browse files Browse the repository at this point in the history
Resolves #654
  • Loading branch information
MarcT512 committed Aug 7, 2020
1 parent 730e3d0 commit 4e9e44e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/json_parse.c
Expand Up @@ -82,7 +82,8 @@ static int parseit(int fd, int (*callback)(struct json_object *))
int parse_end = json_tokener_get_parse_end(tok);
if (obj == NULL && jerr != json_tokener_continue)
{
char *aterr = &buf[start_pos + parse_end];
char *aterr = (start_pos + parse_end < sizeof(buf)) ?
&buf[start_pos + parse_end] : "";
fflush(stdout);
int fail_offset = total_read - ret + start_pos + parse_end;
fprintf(stderr, "Failed at offset %d: %s %c\n", fail_offset,
Expand Down

0 comments on commit 4e9e44e

Please sign in to comment.