From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XGqk3-0003H6-Hj for qemu-devel@nongnu.org; Mon, 11 Aug 2014 10:38:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XGqjx-0006EI-9Q for qemu-devel@nongnu.org; Mon, 11 Aug 2014 10:38:31 -0400 Received: from mail-we0-x235.google.com ([2a00:1450:400c:c03::235]:64294) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XGqjw-0006EB-Vq for qemu-devel@nongnu.org; Mon, 11 Aug 2014 10:38:25 -0400 Received: by mail-we0-f181.google.com with SMTP id k48so8506762wev.26 for ; Mon, 11 Aug 2014 07:38:24 -0700 (PDT) Date: Mon, 11 Aug 2014 15:38:21 +0100 From: Stefan Hajnoczi Message-ID: <20140811143821.GD496@stefanha-thinkpad.redhat.com> References: <1407739803-22699-1-git-send-email-mitake.hitoshi@lab.ntt.co.jp> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="WChQLJJJfbwij+9x" Content-Disposition: inline In-Reply-To: <1407739803-22699-1-git-send-email-mitake.hitoshi@lab.ntt.co.jp> Subject: Re: [Qemu-devel] [PATCH] qemu-io: initialize progname with error_set_progname() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hitoshi Mitake Cc: Kevin Wolf , mitake.hitoshi@gmail.com, qemu-devel@nongnu.org, Stefan Hajnoczi --WChQLJJJfbwij+9x Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Aug 11, 2014 at 03:50:03PM +0900, Hitoshi Mitake wrote: > Calling error_get_progname() in the context of qemu-io can cause > segmentation fault because qemu-io doesn't initialize its progname > with error_set_progname(). This patch adds the initialization. >=20 > Cc: Kevin Wolf > Cc: Stefan Hajnoczi > Signed-off-by: Hitoshi Mitake > --- > qemu-io.c | 1 + > 1 file changed, 1 insertion(+) >=20 > diff --git a/qemu-io.c b/qemu-io.c > index b55a550..6f08a91 100644 > --- a/qemu-io.c > +++ b/qemu-io.c > @@ -395,6 +395,7 @@ int main(int argc, char **argv) > #endif > =20 > progname =3D basename(argv[0]); > + error_set_progname(progname); =46rom the basename(3) man page: These functions may return pointers to statically allocated memory whic= h may be overwritten by subsequent calls. Since error_set_progname() does not copy its argument, it is not safe to pass the basename(3) return value. Just pass in argv[0] like vl.c does. Please also update the commit description to make it clear that qemu-io currently does not use error_get_progname() so the crash doesn't occur in practice (I guess you discovered it while modifying the code). --WChQLJJJfbwij+9x Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJT6NVdAAoJEJykq7OBq3PI7poH/0VznPhSL0ufdutNFm2CHVML 0naxWmip0AqUkUxSAWPlmjxkj0hlWAvqCesDAuxokhco1qg6lvDM2hXLG02rzWDp MXCKovnfKBOc67Ou1phY74EpYR5PfM0m/9rJugySMKPE7yMGFU7UPbIm4r2bFbvi 9FFWZnCX4NkmW8oKMkLnBBe8lcJhOaH7vltofJWDuRLlEnWSd/zR7OJSHCZoU+QR dx813JP/sk4Mft71fq9n755MGImOSUOhIibqzXMobU5XFEFp/FfN0Uz+4V2UOHAS KFFM7sDtz4lGLW5ZqJ6W0UF20JHdEIQdRgFuTgQ+Cd8TstXRuY7ueRzQyWHNEJQ= =PpaW -----END PGP SIGNATURE----- --WChQLJJJfbwij+9x--