Barenboim / json-parser

JSON parser in standard C

Home Page:https://github.com/sogou/workflow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

heap-buffer-overflow at json_value_parse

NotmebutWind opened this issue · comments

CC=gcc -fsanitize=address make
test.c:
char* jstr = "{ "";
json_value_t *val = json_value_parse(jstr);

use json_value_parse to parse input "{ "" will cause a heap-buffer-overflow error.

==2352670==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000109953 at pc 0x55900a20cc38 bp 0x7ffd112d2dc0 sp 0x7ffd112d2db0
READ of size 1 at 0x602000109953 thread T0
#0 0x55900a20cc37 in json_value_parse /opt1/software/json-parser/json_parser.c:685
#1 0x55900a213a4f in main /opt1/software/json-parser/test.c:184

Thank you. It's a very stupid mistake…… I fixed it in the latest commit: 2b2b689

Can you tell me an example of triggering this error?

commented

The bug has be fixed. Code that triggers the error in the previous version:

void main()
{
    const char *text = "{\"";
    json_value_t *value = json_value_parse(text);
}

Okay, thank you. I understand your point and I have reproduced the problem.