[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] target/i386/hax-posix: fix two 'format-truncation' compile w
From: |
Paolo Bonzini |
Subject: |
Re: [PATCH] target/i386/hax-posix: fix two 'format-truncation' compile warnings |
Date: |
Tue, 3 Mar 2020 11:47:53 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
On 24/02/20 07:51, address@hidden wrote:
> diff --git a/target/i386/hax-posix.c b/target/i386/hax-posix.c
> index a5426a6dac..197d5bc0f9 100644
> --- a/target/i386/hax-posix.c
> +++ b/target/i386/hax-posix.c
> @@ -121,7 +121,8 @@ static char *hax_vm_devfs_string(int vm_id)
> return NULL;
> }
>
> - snprintf(name, sizeof HAX_VM_DEVFS, "/dev/hax_vm/vm%02d", vm_id);
> + int len = snprintf(name, sizeof HAX_VM_DEVFS, "/dev/hax_vm/vm%02d",
> vm_id);
> + assert(len < sizeof HAX_VM_DEVFS);
> return name;
> }
>
> @@ -140,8 +141,9 @@ static char *hax_vcpu_devfs_string(int vm_id, int vcpu_id)
> return NULL;
> }
>
> - snprintf(name, sizeof HAX_VCPU_DEVFS, "/dev/hax_vm%02d/vcpu%02d",
> - vm_id, vcpu_id);
> + int len = snprintf(name, sizeof HAX_VCPU_DEVFS,
> "/dev/hax_vm%02d/vcpu%02d",
> + vm_id, vcpu_id);
> + assert(len < sizeof HAX_VCPU_DEVFS);
> return name;
> }
>
>
Julio Faracco has posted a fix for the same bug. The best change is
actually to switch to g_strdup_printf.
Paolo