From: Eric Blake <eblake@redhat.com>
To: Greg Kurz <gkurz@linux.vnet.ibm.com>,
Amit Shah <amit.shah@redhat.com>,
Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] migration: fix bad string passed to error_report()
Date: Thu, 4 Feb 2016 08:47:42 -0700 [thread overview]
Message-ID: <56B3729E.7070601@redhat.com> (raw)
In-Reply-To: <20160204092007.31588.66396.stgit@bahia.huguette.org>
[-- Attachment #1: Type: text/plain, Size: 1463 bytes --]
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 <gkurz@linux.vnet.ibm.com>
> ---
> 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
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
prev parent reply other threads:[~2016-02-04 15:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-04 9:20 [Qemu-devel] [PATCH] migration: fix bad string passed to error_report() Greg Kurz
2016-02-04 10:00 ` Amit Shah
2016-02-04 10:18 ` [Qemu-trivial] " Greg Kurz
2016-02-04 10:18 ` [Qemu-devel] " Greg Kurz
2016-02-04 15:47 ` Eric Blake [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56B3729E.7070601@redhat.com \
--to=eblake@redhat.com \
--cc=amit.shah@redhat.com \
--cc=gkurz@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.