Received: from eggs.gnu.org ([2001:4830:134:3::10]:48250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eAiUI-0000A3-QJ for qemu-devel@nongnu.org; Fri, 03 Nov 2017 16:22:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eAiUF-0005IJ-MV for qemu-devel@nongnu.org; Fri, 03 Nov 2017 16:22:46 -0400 From: Alberto Garcia In-Reply-To: References: Date: Fri, 03 Nov 2017 21:22:39 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2 3/7] qcow2: Prevent allocating compressed clusters at offset 0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Thomas Huth , "R . Nageswara Sastry" On Fri 03 Nov 2017 05:27:59 PM CET, Max Reitz wrote: >> + if (new_cluster == 0) { >> + qcow2_signal_corruption(bs, true, -1, -1, "Preventing invalid " >> + "allocation of compressed cluster " >> + "at offset 0"); >> + return -EIO; >> + } >> + >> if (!offset || ROUND_UP(offset, s->cluster_size) != new_cluster) { >> offset = new_cluster; >> free_in_cluster = s->cluster_size; >> @@ -1090,7 +1097,6 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size) >> } >> } >> >> - assert(offset); > > I don't think this assert() was meant as a protection against offset > being 0. :-) After the new check offset is now guaranteed to be 0, so what's the point of keeping the assert() ? Berto