]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commit
json: fully parse input string
authorEric Blake <eblake@redhat.com>
Fri, 19 Jun 2015 23:28:22 +0000 (17:28 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 22 Jun 2015 16:38:21 +0000 (10:38 -0600)
commitceb496e5f086a7fc922b8f7e2b1bc38410752306
tree68703c1e2636c9be7d0ea5560bda8c0cbdde1822
parent207afcf6771f7b2de16751b47a06d42922819615
json: fully parse input string

I was adding a JSON test, and was shocked to find out our parser
treated the input string of "1" as invalid JSON.  It turns out
that YAJL specifically documents that it buffers input, and that
if the last input read could be a prefix to a longer token, then
you have to explicitly tell the parser that the buffer has ended
before that token will be processed.

It doesn't help that yajl 2 renamed the function from what it was
in yajl 1.

* src/util/virjson.c (virJSONValueFromString): Complete parse, in
case buffer ends in possible token prefix.
* tests/jsontest.c (mymain): Expose the problem.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/util/virjson.c
tests/jsontest.c