[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] migration: fix bad string passed to error_repor
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH] migration: fix bad string passed to error_report() |
Date: |
Thu, 4 Feb 2016 08:47:42 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
On 02/04/2016 02:20 AM, Greg Kurz wrote:
> state->name does not contain a terminating '\0' and you may get:
>
> Machine type received is 'pseries-2.3y�?' and local is 'pseries-2.4'
> load of migration failed: Invalid argument
>
> Let's add a precision modifier to fix this.
>
> Signed-off-by: Greg Kurz <address@hidden>
> ---
> migration/savevm.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 954988d12130..3335cc23175c 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -299,8 +299,8 @@ static int configuration_post_load(void *opaque, int
> version_id)
> const char *current_name = MACHINE_GET_CLASS(current_machine)->name;
>
> if (strncmp(state->name, current_name, state->len) != 0) {
> - error_report("Machine type received is '%s' and local is '%s'",
> - state->name, current_name);
> + error_report("Machine type received is '%.*s' and local is '%s'",
> + state->len, state->name, current_name);
.* required an 'int', but SaveState.len is uint32_t. There are
platforms (hello, 32-bit cygwin) where uint32_t is a long, and where
this would therefore cause a compiler warning. You'll be safer with an
explicit cast, '(int) state->len'.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature