From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ8ox-0003qd-Go for qemu-devel@nongnu.org; Fri, 22 Mar 2013 16:44:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UJ8ov-0006Hb-OD for qemu-devel@nongnu.org; Fri, 22 Mar 2013 16:44:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44027) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ8ov-0006HD-G8 for qemu-devel@nongnu.org; Fri, 22 Mar 2013 16:44:13 -0400 Message-ID: <514CC295.702@redhat.com> Date: Fri, 22 Mar 2013 14:44:05 -0600 From: Eric Blake MIME-Version: 1.0 References: <20130322163107.489dd941@doriath> In-Reply-To: <20130322163107.489dd941@doriath> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2NBMNJUVVGMFQSQMKKXUV" Subject: Re: [Qemu-devel] [PATCH] qemu-ga: ga_get_fd_handle(): abort if fd_counter overflows List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: qemu-devel , mdroth@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2NBMNJUVVGMFQSQMKKXUV Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 03/22/2013 02:31 PM, Luiz Capitulino wrote: > Today we reset fd_counter if it wraps, but it's better to abort() > instead, as fd_counter should never reach INT64_MAX. >=20 > Signed-off-by: Luiz Capitulino > --- > qga/main.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/qga/main.c b/qga/main.c > index 74ef788..5f505a2 100644 > --- a/qga/main.c > +++ b/qga/main.c > @@ -889,9 +889,13 @@ int64_t ga_get_fd_handle(GAState *s, Error **errp)= > g_assert(!ga_is_frozen(s)); > =20 > handle =3D s->pstate.fd_counter++; > - if (s->pstate.fd_counter < 0) { > - s->pstate.fd_counter =3D 0; > + > + /* This should never happen on a resonable timeframe, as guest-fil= e-open s/resonable/reasonable/ > + * would have to be issued 2^63 times */ > + if (s->pstate.fd_counter =3D=3D INT64_MAX) { > + abort(); Fix the typo, and you can add: Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2NBMNJUVVGMFQSQMKKXUV 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.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRTMKVAAoJEKeha0olJ0NqlSsH/1WMVDfT6fTJl/A1AfpLrHPu 7lq8L4sEsaFHl5B7ZcLU9DK8RGr06nGifHLQG5oxDvAfvSLrUVLSp6WHVrZtGtOy q/9qv4DUGzeIalQyxf/s8twg4gN1wMrfaACKEaikD81gCpmwTWBqopOErBljPFzT wrNH2kX0VBM0O5AGadhowbx6f377cKnVky3un/DjCV57P7HyaM+U4bxY51BrSYYj 8JopXbuw2zTe91InPwWsTGGFovuw+Kc6fJalxYahrtfV0pLZ7F3s/iSejJXelAU9 3wFatcnQ5Zb/tVuFgT0E7/7jl2EikvMcrzVfu1QO1DiU0G5BH7ZIzyjD9iqVwfc= =gGHd -----END PGP SIGNATURE----- ------enig2NBMNJUVVGMFQSQMKKXUV--