From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XnzKi-0006La-2D for qemu-devel@nongnu.org; Mon, 10 Nov 2014 19:29:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XnzKd-0000Ni-3x for qemu-devel@nongnu.org; Mon, 10 Nov 2014 19:29:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XnzKc-0000Nc-Th for qemu-devel@nongnu.org; Mon, 10 Nov 2014 19:29:15 -0500 Message-ID: <54615850.4050809@redhat.com> Date: Mon, 10 Nov 2014 17:29:04 -0700 From: Eric Blake MIME-Version: 1.0 References: <1415627159-15941-1-git-send-email-mreitz@redhat.com> <1415627159-15941-9-git-send-email-mreitz@redhat.com> In-Reply-To: <1415627159-15941-9-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hWO4LcQSO83BDp76uTCqQ2JqNp7T6dwta" Subject: Re: [Qemu-devel] [PATCH 08/21] qcow2: More helpers for refcount modification List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Lieven , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --hWO4LcQSO83BDp76uTCqQ2JqNp7T6dwta Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/10/2014 06:45 AM, Max Reitz wrote: > Add helper functions for getting and setting refcounts in a refcount > array for any possible refcount order, and choose the correct one durin= g > refcount initialization. >=20 > Signed-off-by: Max Reitz > --- > block/qcow2-refcount.c | 143 +++++++++++++++++++++++++++++++++++++++++= +++++++- > 1 file changed, 141 insertions(+), 2 deletions(-) >=20 > + > +static uint64_t get_refcount_ro6(const void *refcount_array, uint64_t = index) > +{ > + return be64_to_cpu(((const uint64_t *)refcount_array)[index]); > +} Should this return int64_t and error out if the user ever exceeded 2**63 via image fuzzing? > + > +static void set_refcount_ro6(void *refcount_array, uint64_t index, > + uint64_t value) > +{ > + ((uint64_t *)refcount_array)[index] =3D cpu_to_be64(value); > +} Should this assert that value <=3D INT64_MAX, since that's what the rest of the code caps it to? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --hWO4LcQSO83BDp76uTCqQ2JqNp7T6dwta Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAEBCAAGBQJUYVhQAAoJEKeha0olJ0NqsO4H/A88SGLehiW08cnJiZhQv1VC 5kWxEoBJ4V++Cz501fbrenYcpF4pbnoAT5kjWcqAlNrLhGXJ2XvuMXZhbK8FZwb8 6TUCCU7OiEYk6cM1bMrifC1mks4ljReDrIgfC7N1FkarzNNeQaoTp40tNHoIQOxQ ah9xhiv4n3LSUgtdXSUHgnEkpPHZOHDfP9ifvZPk8zErx5ux6RvMtEFcw+WdJAaO /fu/49DTId/PixKpry/nblPGChJPi4ro2Rkw1Cyt2322NAqmtuvBUvD4m8ND/2WI 2YnArJ25AHyeJ9lO0/5DA6mQeegmObg7rJDXKbMunCvnE6oOfwcwSB4sbEPosOM= =bF7m -----END PGP SIGNATURE----- --hWO4LcQSO83BDp76uTCqQ2JqNp7T6dwta--