From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:49029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui3n2-00078X-62 for qemu-devel@nongnu.org; Thu, 30 May 2013 10:25:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ui3mx-0001rW-DT for qemu-devel@nongnu.org; Thu, 30 May 2013 10:25:16 -0400 Message-ID: <51A76145.1010304@redhat.com> Date: Thu, 30 May 2013 08:25:09 -0600 From: Eric Blake MIME-Version: 1.0 References: <1369923286-22260-1-git-send-email-stefanha@redhat.com> <1369923286-22260-4-git-send-email-stefanha@redhat.com> In-Reply-To: <1369923286-22260-4-git-send-email-stefanha@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2WDDFMHVMCMEBMCISPWGO" Subject: Re: [Qemu-devel] [PATCH 3/3] savevm: avoid leaking popen(3) file pointer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Markus Armbruster , Juan Quintela , qemu-devel@nongnu.org, qemu-stable@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2WDDFMHVMCMEBMCISPWGO Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/30/2013 08:14 AM, Stefan Hajnoczi wrote: > I'm not sure why we check the mode only after invoking popen(3) but we > need to close the file pointer. >=20 > Spotted by Coverity. >=20 > Cc: Juan Quintela > Cc: qemu-stable@nongnu.org > Signed-off-by: Stefan Hajnoczi > --- > savevm.c | 1 + > 1 file changed, 1 insertion(+) >=20 > diff --git a/savevm.c b/savevm.c > index 31dcce9..75cc72e 100644 > --- a/savevm.c > +++ b/savevm.c > @@ -329,6 +329,7 @@ QEMUFile *qemu_popen_cmd(const char *command, const= char *mode) > =20 > if (mode =3D=3D NULL || (mode[0] !=3D 'r' && mode[0] !=3D 'w') || = mode[1] !=3D 0) { > fprintf(stderr, "qemu_popen: Argument validity check failed\n"= ); > + fclose(stdio_file); You MUST use pclose() (not fclose) on any FILE obtained by popen(), to avoid resource leaks. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2WDDFMHVMCMEBMCISPWGO 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/ iQEcBAEBCAAGBQJRp2FFAAoJEKeha0olJ0NqxAQIAKCDR+zo55/eeGHDZXHnohJe 2BbbOte3qz4Zu3KdjHGqLo/Zo6oGtz4XkoMbnTrs4pGBet0bWjumHrkPVs5wNnYw blyfdRAmW6F5xq2rs5CjyzT2rgh5ynemMzMlojQpU3KANmX3cxlOu1BSrJsoyEwP UWmje2vWvm8duOqdtaYWZi0U3P8dcyP7kn1DKVGibWIBv1A+3O4UsOwmJiP3Gyk4 dFZJXXuQgzcBtkd+BDqWPeUf2tACkB8VVUmJ2bE6kfEjKbVPU+grXeWmSyQdiJwT ktlqh9+MexYvF2F9fdiGV0Rqm0+NkMr2ppwkSlanV13xz7/aNZLIlIVvYPa9nhI= =eRQx -----END PGP SIGNATURE----- ------enig2WDDFMHVMCMEBMCISPWGO--