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: 8530001 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AECC99F372 for ; Tue, 8 Mar 2016 07:01:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2011020121 for ; Tue, 8 Mar 2016 07:01:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6E5B22010B for ; Tue, 8 Mar 2016 07:01:45 +0000 (UTC) Received: from localhost ([::1]:60741 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adBeK-0002pL-Rj for patchwork-qemu-devel@patchwork.kernel.org; Tue, 08 Mar 2016 02:01:44 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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];