From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XH4WQ-00087D-S2 for qemu-devel@nongnu.org; Tue, 12 Aug 2014 01:21:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XH4WK-0003QM-MU for qemu-devel@nongnu.org; Tue, 12 Aug 2014 01:21:22 -0400 Received: from mail-pd0-x230.google.com ([2607:f8b0:400e:c02::230]:42117) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XH4WK-0003QA-Fk for qemu-devel@nongnu.org; Tue, 12 Aug 2014 01:21:16 -0400 Received: by mail-pd0-f176.google.com with SMTP id y10so11956296pdj.21 for ; Mon, 11 Aug 2014 22:21:15 -0700 (PDT) Sender: Hitoshi Mitake Date: Tue, 12 Aug 2014 14:21:11 +0900 Message-ID: <87fvh2s2pk.wl%mitake.hitoshi@lab.ntt.co.jp> From: Hitoshi Mitake In-Reply-To: <20140811143821.GD496@stefanha-thinkpad.redhat.com> References: <1407739803-22699-1-git-send-email-mitake.hitoshi@lab.ntt.co.jp> <20140811143821.GD496@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII 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: Stefan Hajnoczi Cc: Kevin Wolf , mitake.hitoshi@gmail.com, Hitoshi Mitake , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi At Mon, 11 Aug 2014 15:38:21 +0100, Stefan Hajnoczi wrote: > > [1 ] > 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. > > > > Cc: Kevin Wolf > > Cc: Stefan Hajnoczi > > Signed-off-by: Hitoshi Mitake > > --- > > qemu-io.c | 1 + > > 1 file changed, 1 insertion(+) > > > > 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 > > > > progname = basename(argv[0]); > > + error_set_progname(progname); Hi Stefan, thanks for your comments. > > From the basename(3) man page: > > These functions may return pointers to statically allocated memory which 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. Thanks for your pointing. I'll update it in v2. > > 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). > [2 ] > Yes, as you guess, I discoverd it during modifying sheepdog block driver for internal purpose. The patch is just for proactive action. Thanks, Hitoshi