From patchwork Tue Apr 12 16:19:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 8812481 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 1533B9F3A0 for ; Tue, 12 Apr 2016 16:24:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7F66D201EF for ; Tue, 12 Apr 2016 16:24:18 +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 D9F82201FA for ; Tue, 12 Apr 2016 16:24:17 +0000 (UTC) Received: from localhost ([::1]:52829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aq16v-0006eH-4f for patchwork-qemu-devel@patchwork.kernel.org; Tue, 12 Apr 2016 12:24:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aq12N-00056i-M2 for qemu-devel@nongnu.org; Tue, 12 Apr 2016 12:19:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aq12J-0007i5-R5 for qemu-devel@nongnu.org; Tue, 12 Apr 2016 12:19:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34425) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aq12C-0007dd-QT; Tue, 12 Apr 2016 12:19:24 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 826923B755; Tue, 12 Apr 2016 16:19:24 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-111.ams2.redhat.com [10.36.116.111]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3CGJ9W6005137; Tue, 12 Apr 2016 12:19:23 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 12 Apr 2016 18:19:01 +0200 Message-Id: <1460477948-24686-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1460477948-24686-1-git-send-email-kwolf@redhat.com> References: <1460477948-24686-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/13] qcow2: Prevent backing file names longer than 1023 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 From: Max Reitz We reject backing file names with a length of more than 1023 characters when opening a qcow2 file, so we should not produce such files ourselves. Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- block/qcow2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 056525c..470734b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1986,6 +1986,10 @@ static int qcow2_change_backing_file(BlockDriverState *bs, { BDRVQcow2State *s = bs->opaque; + if (backing_file && strlen(backing_file) > 1023) { + return -EINVAL; + } + pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_file ?: ""); pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_fmt ?: "");