From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrmZa-00049g-NF for qemu-devel@nongnu.org; Thu, 29 Oct 2015 08:45:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrmZV-0006Mf-LQ for qemu-devel@nongnu.org; Thu, 29 Oct 2015 08:44:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53448) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrmZV-0006Ll-EQ for qemu-devel@nongnu.org; Thu, 29 Oct 2015 08:44:49 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id D8EC5C0B5922 for ; Thu, 29 Oct 2015 12:44:45 +0000 (UTC) From: Markus Armbruster Date: Thu, 29 Oct 2015 13:44:41 +0100 Message-Id: <1446122683-2355-3-git-send-email-armbru@redhat.com> In-Reply-To: <1446122683-2355-1-git-send-email-armbru@redhat.com> References: <1446122683-2355-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH 2/4] json-streamer: Don't crash when input exceeds nesting limit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: lcapitulino@redhat.com We limit nesting depth and input size to defend against input triggering excessive heap or stack memory use (commit 29c75dd json-streamer: limit the maximum recursion depth and maximum token count). However, when the nesting limit is exceeded, parser_context_peek_token()'s assertion fails. Broken in commit 65c0f1e "json-parser: don't replicate tokens at each level of recursion". To reproduce stuff 1025 open braces or brackets into QMP. Fix by taking the error exit instead of the normal one. Reported-by: Eric Blake Signed-off-by: Markus Armbruster --- qobject/json-streamer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qobject/json-streamer.c b/qobject/json-streamer.c index dced2c7..755c74d 100644 --- a/qobject/json-streamer.c +++ b/qobject/json-streamer.c @@ -68,7 +68,7 @@ static void json_message_process_token(JSONLexer *lexer, QString *token, JSONTok /* Security consideration, we limit total memory allocated per object * and the maximum recursion depth that a message can force. */ - goto out_emit; + goto out_emit_bad; } return; -- 2.4.3