]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qjson: Apply nesting limit more sanely
authorMarkus Armbruster <armbru@redhat.com>
Wed, 25 Nov 2015 21:23:22 +0000 (22:23 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Thu, 26 Nov 2015 08:17:57 +0000 (09:17 +0100)
The nesting limit from commit 29c75dd "json-streamer: limit the
maximum recursion depth and maximum token count" applies separately to
braces and brackets.  This makes no sense.  Apply it to their sum,
because that's actually a measure of recursion depth.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1448486613-17634-2-git-send-email-armbru@redhat.com>

qobject/json-streamer.c

index 1b2f9b1d107c3cf09721e653bdc8b94a426e1481..dced2c77a19b2a83b9c9c4b2b6cc0252b906c21c 100644 (file)
@@ -64,8 +64,7 @@ static void json_message_process_token(JSONLexer *lexer, QString *token, JSONTok
          parser->bracket_count == 0)) {
         goto out_emit;
     } else if (parser->token_size > MAX_TOKEN_SIZE ||
-               parser->bracket_count > MAX_NESTING ||
-               parser->brace_count > MAX_NESTING) {
+               parser->bracket_count + parser->brace_count > MAX_NESTING) {
         /* Security consideration, we limit total memory allocated per object
          * and the maximum recursion depth that a message can force.
          */