From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WW5kB-0006vp-M2 for qemu-devel@nongnu.org; Fri, 04 Apr 2014 11:09:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WW5k5-00051a-J6 for qemu-devel@nongnu.org; Fri, 04 Apr 2014 11:09:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46341) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WW5k5-00051U-BA for qemu-devel@nongnu.org; Fri, 04 Apr 2014 11:09:17 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s34F9GQe031467 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 4 Apr 2014 11:09:16 -0400 From: Kevin Wolf Date: Fri, 4 Apr 2014 17:09:13 +0200 Message-Id: <1396624153-7461-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] block: Check bdrv_getlength() return value in bdrv_append_temp_snapshot() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, mreitz@redhat.com Signed-off-by: Kevin Wolf --- block.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index d89c344..990a754 100644 --- a/block.c +++ b/block.c @@ -1184,7 +1184,12 @@ void bdrv_append_temp_snapshot(BlockDriverState *bs, Error **errp) instead of opening 'filename' directly */ /* Get the required size from the image */ - total_size = bdrv_getlength(bs) & BDRV_SECTOR_MASK; + total_size = bdrv_getlength(bs); + if (total_size < 0) { + error_setg_errno(errp, -total_size, "Could not get image size"); + return; + } + total_size &= BDRV_SECTOR_MASK; /* Create the temporary image */ ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename)); -- 1.8.3.1