From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WStzL-00053n-K3 for qemu-devel@nongnu.org; Wed, 26 Mar 2014 15:59:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WStzF-0007yR-H2 for qemu-devel@nongnu.org; Wed, 26 Mar 2014 15:59:51 -0400 Message-ID: <533331AA.8020007@redhat.com> Date: Wed, 26 Mar 2014 20:59:38 +0100 From: Max Reitz MIME-Version: 1.0 References: <1395835569-21193-1-git-send-email-stefanha@redhat.com> <1395835569-21193-10-git-send-email-stefanha@redhat.com> In-Reply-To: <1395835569-21193-10-git-send-email-stefanha@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH for-2.0 09/47] bochs: Unify header structs and make them QEMU_PACKED List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , qemu-devel@nongnu.org Cc: Kevin Wolf , pmatouse@redhat.com, qemu-stable@nongnu.org On 26.03.2014 13:05, Stefan Hajnoczi wrote: > From: Kevin Wolf > > This is an on-disk structure, so offsets must be accurate. > > Before this patch, sizeof(bochs) != sizeof(header_v1), which makes the > memcpy() between both invalid. We're lucky enough that the destination > buffer happened to be the larger one, and the memcpy size to be taken > from the smaller one, so we didn't get a buffer overflow in practice. > > This patch unifies the both structures, eliminating the need to do a > memcpy in the first place. The common fields are extracted to the top > level of the struct and the actually differing part gets a union of the > two versions. > > Signed-off-by: Kevin Wolf > Reviewed-by: Stefan Hajnoczi > --- > block/bochs.c | 67 ++++++++++++++++++++++------------------------------------- > 1 file changed, 25 insertions(+), 42 deletions(-) Reviewed-by: Max Reitz