From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYWMc-00075B-9F for qemu-devel@nongnu.org; Tue, 22 Oct 2013 03:26:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VYWMV-0002yZ-Ha for qemu-devel@nongnu.org; Tue, 22 Oct 2013 03:26:50 -0400 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:54508 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYWMV-0002xy-6A for qemu-devel@nongnu.org; Tue, 22 Oct 2013 03:26:43 -0400 Message-ID: <526628B0.70607@kamp.de> Date: Tue, 22 Oct 2013 09:26:40 +0200 From: Peter Lieven MIME-Version: 1.0 References: <1382424205-19742-1-git-send-email-pl@kamp.de> <5266223D.4080507@redhat.com> In-Reply-To: <5266223D.4080507@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] block/vpc: check that the image has not been truncated List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, aliguori@us.ibm.com, jcody@redhat.com, stefanha@redhat.com On 22.10.2013 08:59, Eric Blake wrote: > On 10/22/2013 07:43 AM, Peter Lieven wrote: >> this adds a check that a dynamic VHD file has not been >> accidently truncated (e.g. during transfer or upload). >> >> Signed-off-by: Peter Lieven >> --- >> block/vpc.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/block/vpc.c b/block/vpc.c >> index 1acc1d4..921364e 100644 >> --- a/block/vpc.c >> +++ b/block/vpc.c >> @@ -269,6 +269,13 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, >> } >> } >> >> + if (s->free_data_block_offset > bdrv_getlength(bs->file)) { >> + ret = -EINVAL; >> + fprintf(stderr, "block-vpc: free_data_block_offset points after" >> + "the end of file. the image has been truncated.\n"); > Why fprintf() instead of using the errp argument? wasn't aware. a few lines earlier fprintf(stderr, ...) was used. if the others are otherwise happy with the patch I will send a v2. Peter