Skip to content

Commit 4e9e44e

Browse files
authored
Fix read past end of buffer
Resolves json-c#654
1 parent 730e3d0 commit 4e9e44e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

apps/json_parse.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ static int parseit(int fd, int (*callback)(struct json_object *))
8282
int parse_end = json_tokener_get_parse_end(tok);
8383
if (obj == NULL && jerr != json_tokener_continue)
8484
{
85-
char *aterr = &buf[start_pos + parse_end];
85+
char *aterr = (start_pos + parse_end < sizeof(buf)) ?
86+
&buf[start_pos + parse_end] : "";
8687
fflush(stdout);
8788
int fail_offset = total_read - ret + start_pos + parse_end;
8889
fprintf(stderr, "Failed at offset %d: %s %c\n", fail_offset,

0 commit comments

Comments
 (0)