From patchwork Tue Aug 6 01:40:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 264829 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 468932C0085 for ; Tue, 6 Aug 2013 11:42:03 +1000 (EST) Received: from localhost ([::1]:41199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6WHh-00057w-Ez for incoming@patchwork.ozlabs.org; Mon, 05 Aug 2013 21:42:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52428) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6WH9-0004zg-Vp for qemu-devel@nongnu.org; Mon, 05 Aug 2013 21:41:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V6WH3-00073Q-Vd for qemu-devel@nongnu.org; Mon, 05 Aug 2013 21:41:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6WH3-00073E-OA for qemu-devel@nongnu.org; Mon, 05 Aug 2013 21:41:21 -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 r761fLxG019157 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 5 Aug 2013 21:41:21 -0400 Received: from T430s.redhat.com (vpn1-5-221.sin2.redhat.com [10.67.5.221]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r761f1Is004035; Mon, 5 Aug 2013 21:41:17 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 6 Aug 2013 09:40:36 +0800 Message-Id: <1375753243-19530-4-git-send-email-famz@redhat.com> In-Reply-To: <1375753243-19530-1-git-send-email-famz@redhat.com> References: <1375753243-19530-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pmatouse@redhat.com, jcody@redhat.com, armbru@redhat.com, stefanha@redhat.com, famz@redhat.com, asias@redhat.com, areis@redhat.com Subject: [Qemu-devel] [PATCH v3 03/10] vmdk: use unsigned values for on disk header fields X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The size and offset fields are all non-negative values, use uint64_t for them to avoid getting negative in memory value by int overflow. Signed-off-by: Fam Zheng --- block/vmdk.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 7ebe36b..976b871 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -67,14 +67,14 @@ typedef struct { typedef struct { uint32_t version; uint32_t flags; - int64_t capacity; - int64_t granularity; - int64_t desc_offset; - int64_t desc_size; - int32_t num_gtes_per_gte; - int64_t rgd_offset; - int64_t gd_offset; - int64_t grain_offset; + uint64_t capacity; + uint64_t granularity; + uint64_t desc_offset; + uint64_t desc_size; + uint32_t num_gtes_per_gte; + uint64_t rgd_offset; + uint64_t gd_offset; + uint64_t grain_offset; char filler[1]; char check_bytes[4]; uint16_t compressAlgorithm;