Hitoshi Mitake <mitake.hito...@lab.ntt.co.jp> writes:

> 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 <kw...@redhat.com>
> Cc: Stefan Hajnoczi <stefa...@redhat.com>
> Signed-off-by: Hitoshi Mitake <mitake.hito...@lab.ntt.co.jp>
> ---
>  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);
>      qemu_init_exec_dir(argv[0]);
>  
>      while ((c = getopt_long(argc, argv, sopt, lopt, &opt_index)) != -1) {

Global variable progname could be replaced by error_get_progname().

Can pass argv[0] directly, without basename().

Do any other programs besides qemu-io and qemu proper need to call
error_set_progname()?  Quick grep for main() finds

    qemu-bridge-helper.c
    qemu-io.c
    qemu-nbd.c
    bsd-user/main.c
    disas/m68k.c
    fsdev/virtfs-proxy-helper.c
    libcacard/link_test.c
    libcacard/vscclient.c
    linux-user/main.c
    qga/main.c
    target-ppc/mfrom_table_gen.c
    pc-bios/s390-ccw/main.c

Reviewed-by: Markus Armbruster <arm...@redhat.com>

Reply via email to