From: Remi Collet Date: Fri, 23 Aug 2013 11:40:01 +0000 (+0200) Subject: trailing char not allowed in strict mode X-Git-Tag: json-c-0.12-20140410~32^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F94%2Fhead;p=thirdparty%2Fjson-c.git trailing char not allowed in strict mode --- diff --git a/json_tokener.c b/json_tokener.c index 7ce53ca7..def6e108 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -769,6 +769,13 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, } /* while(POP_CHAR) */ out: + if (c && + (state == json_tokener_state_finish) && + (tok->depth == 0) && + (tok->flags & JSON_TOKENER_STRICT)) { + /* unexpected char after JSON data */ + tok->err = json_tokener_error_parse_unexpected; + } if (!c) { /* We hit an eof char (0) */ if(state != json_tokener_state_finish && saved_state != json_tokener_state_finish)