7cd991b json: reject trailing garbage

2 files Authored by ericb 8 years ago, Committed by mprivozn 8 years ago,
    json: reject trailing garbage
    
    Yajl 2 has a nice feature that it can be configured whether to
    allow multiple JSON objects parsed from a single stream, defaulting
    to off.  And yajl 1.0.12 at least provided a way to tell if all
    input bytes were parsed, or if trailing bytes remained after a
    valid JSON object was parsed.  But we target RHEL 6 yajl 1.0.7,
    which has neither of these.  So fake it by always parsing '[...]'
    instead, so that trailing garbage either trips up the array parse,
    or is easily detected when unwrapping the result.
    
    * src/util/virjson.c (virJSONValueFromString): With older json,
    wrap text to avoid trailing garbage.
    * tests/jsontest.c (mymain): Add tests for this.
    
    Signed-off-by: Eric Blake <eblake@redhat.com>
    
        
file modified
+28 -1
file modified
+2 -0