qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qemu-io: initialize progname with error_set_pro


From: Hitoshi Mitake
Subject: Re: [Qemu-devel] [PATCH] qemu-io: initialize progname with error_set_progname()
Date: Tue, 12 Aug 2014 14:21:11 +0900
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Goj$(D+W(B) APEL/10.8 Emacs/23.4 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

At Mon, 11 Aug 2014 15:38:21 +0100,
Stefan Hajnoczi wrote:
> 
> [1  <text/plain; us-ascii (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.
> > 
> > Cc: Kevin Wolf <address@hidden>
> > Cc: Stefan Hajnoczi <address@hidden>
> > Signed-off-by: Hitoshi Mitake <address@hidden>
> > ---
> >  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  <application/pgp-signature (7bit)>]
> 

Yes, as you guess, I discoverd it during modifying sheepdog block
driver for internal purpose. The patch is just for proactive action.

Thanks,
Hitoshi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]