From patchwork Tue Mar 8 07:00:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 593897 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6AA11140779 for ; Tue, 8 Mar 2016 18:02:06 +1100 (AEDT) Received: from localhost ([::1]:60745 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adBee-0003sb-Ho for incoming@patchwork.ozlabs.org; Tue, 08 Mar 2016 02:02:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adBe4-0002f2-12 for qemu-devel@nongnu.org; Tue, 08 Mar 2016 02:01:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adBdy-0006PC-43 for qemu-devel@nongnu.org; Tue, 08 Mar 2016 02:01:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41122) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adBdt-0006L8-EQ; Tue, 08 Mar 2016 02:01:17 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 03FA77304F; Tue, 8 Mar 2016 07:01:17 +0000 (UTC) Received: from pxdev.xzpeter.org.com (vpn1-5-232.pek2.redhat.com [10.72.5.232]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2870qvM019713; Tue, 8 Mar 2016 02:01:11 -0500 From: Peter Xu To: qemu-devel@nongnu.org Date: Tue, 8 Mar 2016 15:00:40 +0800 Message-Id: <1457420446-25276-3-git-send-email-peterx@redhat.com> In-Reply-To: <1457420446-25276-1-git-send-email-peterx@redhat.com> References: <1457420446-25276-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 08 Mar 2016 07:01:17 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Cc: Kevin Wolf , pbonzini@redhat.com, qemu-block@nongnu.org, Markus Armbruster , peterx@redhat.com Subject: [Qemu-devel] [PATCH 2/8] block: fix unbounded stack for dump_qdict X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Suggested-by: Paolo Bonzini CC: Markus Armbruster CC: Kevin Wolf CC: qemu-block@nongnu.org Signed-off-by: Peter Xu --- block/qapi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/qapi.c b/block/qapi.c index db2d3fb..687e577 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -638,9 +638,12 @@ static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation, QType type = qobject_type(entry->value); bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST); const char *format = composite ? "%*s%s:\n" : "%*s%s: "; - char key[strlen(entry->key) + 1]; +#define __KEY_LEN (256) + char key[__KEY_LEN]; int i; + assert(strlen(entry->key) + 1 <= __KEY_LEN); +#undef __KEY_LEN /* replace dashes with spaces in key (variable) names */ for (i = 0; entry->key[i]; i++) { key[i] = entry->key[i] == '-' ? ' ' : entry->key[i];