From patchwork Wed Oct 17 08:27:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 10645097 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5B92C109C for ; Wed, 17 Oct 2018 08:56:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A98928AA8 for ; Wed, 17 Oct 2018 08:56:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E55428CFE; Wed, 17 Oct 2018 08:56:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id EA2CA28AA8 for ; Wed, 17 Oct 2018 08:56:25 +0000 (UTC) Received: from localhost ([::1]:34654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChcv-0007wt-3V for patchwork-qemu-devel@patchwork.kernel.org; Wed, 17 Oct 2018 04:56:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChFo-0004TS-Uk for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:32:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChFk-00077B-DN for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:32:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43494) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChFk-000767-6c for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:32:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 902B767EC2 for ; Wed, 17 Oct 2018 08:32:27 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C1B05DDFF; Wed, 17 Oct 2018 08:32:27 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9E9F51162B63; Wed, 17 Oct 2018 10:27:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 10:27:02 +0200 Message-Id: <20181017082702.5581-39-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 17 Oct 2018 08:32:27 +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 Subject: [Qemu-devel] [PATCH v4 38/38] vpc: Fail open on bad header checksum 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: Kevin Wolf Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP vpc_open() merely prints a warning when it finds a bad header checksum. Turn that into a hard error. Cc: Kevin Wolf Signed-off-by: Markus Armbruster Reviewed-by: Kevin Wolf --- block/vpc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/block/vpc.c b/block/vpc.c index bf294abfa7..1729c0cb44 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -284,9 +284,11 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, checksum = be32_to_cpu(footer->checksum); footer->checksum = 0; - if (vpc_checksum(s->footer_buf, HEADER_SIZE) != checksum) - fprintf(stderr, "block-vpc: The header checksum of '%s' is " - "incorrect.\n", bs->filename); + if (vpc_checksum(s->footer_buf, HEADER_SIZE) != checksum) { + error_setg(errp, "incorrect header checksum"); + ret = -EINVAL; + goto fail; + } /* Write 'checksum' back to footer, or else will leave it with zero. */ footer->checksum = cpu_to_be32(checksum);