34b321
From 1f08301adf98c235ccc4e978f809c3f60833452c Mon Sep 17 00:00:00 2001
34b321
From: Markus Armbruster <armbru@redhat.com>
34b321
Date: Wed, 27 Jul 2016 07:35:00 +0200
34b321
Subject: [PATCH 02/16] qjson: Apply nesting limit more sanely
34b321
34b321
RH-Author: Markus Armbruster <armbru@redhat.com>
34b321
Message-id: <1469604913-12442-4-git-send-email-armbru@redhat.com>
34b321
Patchwork-id: 71468
34b321
O-Subject: [RHEL-7.3 qemu-kvm PATCH v2 02/15] qjson: Apply nesting limit more sanely
34b321
Bugzilla: 1276036
34b321
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
RH-Acked-by: John Snow <jsnow@redhat.com>
34b321
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
34b321
34b321
The nesting limit from commit 29c75dd "json-streamer: limit the
34b321
maximum recursion depth and maximum token count" applies separately to
34b321
braces and brackets.  This makes no sense.  Apply it to their sum,
34b321
because that's actually a measure of recursion depth.
34b321
34b321
Signed-off-by: Markus Armbruster <armbru@redhat.com>
34b321
Reviewed-by: Eric Blake <eblake@redhat.com>
34b321
Message-Id: <1448486613-17634-2-git-send-email-armbru@redhat.com>
34b321
(cherry picked from commit 4f2d31fbc0bfdf41feea7d1be49f4f7ffa005534)
34b321
Signed-off-by: Markus Armbruster <armbru@redhat.com>
34b321
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
---
34b321
 qobject/json-streamer.c | 3 +--
34b321
 1 file changed, 1 insertion(+), 2 deletions(-)
34b321
34b321
diff --git a/qobject/json-streamer.c b/qobject/json-streamer.c
34b321
index 1b2f9b1..dced2c7 100644
34b321
--- a/qobject/json-streamer.c
34b321
+++ b/qobject/json-streamer.c
34b321
@@ -64,8 +64,7 @@ static void json_message_process_token(JSONLexer *lexer, QString *token, JSONTok
34b321
          parser->bracket_count == 0)) {
34b321
         goto out_emit;
34b321
     } else if (parser->token_size > MAX_TOKEN_SIZE ||
34b321
-               parser->bracket_count > MAX_NESTING ||
34b321
-               parser->brace_count > MAX_NESTING) {
34b321
+               parser->bracket_count + parser->brace_count > MAX_NESTING) {
34b321
         /* Security consideration, we limit total memory allocated per object
34b321
          * and the maximum recursion depth that a message can force.
34b321
          */
34b321
-- 
34b321
1.8.3.1
34b321