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: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH] qemu-io: initialize progname with error_set_progname()
Date: Mon, 11 Aug 2014 15:38:21 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

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);

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.

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).

Attachment: pgpuGlStr4hOL.pgp
Description: PGP signature


reply via email to

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