Received: from eggs.gnu.org ([2001:4830:134:3::10]:40007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WW9me-0007UX-Ff for qemu-devel@nongnu.org; Fri, 04 Apr 2014 15:28:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WW9mW-0007g5-Ps for qemu-devel@nongnu.org; Fri, 04 Apr 2014 15:28:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23565) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WW9mW-0007g1-Hf for qemu-devel@nongnu.org; Fri, 04 Apr 2014 15:28:04 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s34JS3Mg025732 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 4 Apr 2014 15:28:04 -0400 From: Kevin Wolf Date: Fri, 4 Apr 2014 21:27:46 +0200 Message-Id: <1396639669-24348-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1396639669-24348-1-git-send-email-kwolf@redhat.com> References: <1396639669-24348-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 07/10] 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 Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- 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