All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] migration: fix bad string passed to error_report()
@ 2016-02-04  9:20 Greg Kurz
  2016-02-04 10:00 ` Amit Shah
  2016-02-04 15:47 ` Eric Blake
  0 siblings, 2 replies; 4+ messages in thread
From: Greg Kurz @ 2016-02-04  9:20 UTC (permalink / raw)
  To: Amit Shah, Juan Quintela; +Cc: qemu-devel

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);
         return -EINVAL;
     }
     return 0;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: fix bad string passed to error_report()
  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   ` Greg Kurz
  2016-02-04 15:47 ` Eric Blake
  1 sibling, 1 reply; 4+ messages in thread
From: Amit Shah @ 2016-02-04 10:00 UTC (permalink / raw)
  To: Greg Kurz; +Cc: qemu-devel, Juan Quintela

On (Thu) 04 Feb 2016 [10:20:07], 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>

Reviewed-by: Amit Shah <amit.shah@redhat.com>

		Amit

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: fix bad string passed to error_report()
  2016-02-04 10:00 ` Amit Shah
@ 2016-02-04 10:18   ` Greg Kurz
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kurz @ 2016-02-04 10:18 UTC (permalink / raw)
  To: Amit Shah; +Cc: qemu-trivial, qemu-stable, qemu-devel, Juan Quintela

On Thu, 4 Feb 2016 15:30:11 +0530
Amit Shah <amit.shah@redhat.com> wrote:

> On (Thu) 04 Feb 2016 [10:20:07], 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>  
> 
> Reviewed-by: Amit Shah <amit.shah@redhat.com>
> 
> 		Amit
> 

I forgot to mention that this patch fixes:

61964c23e5ddd5a33f15699e45ce126f879e3e33 "migration: Add configuration section"

Cc'ing stable since this is a 2.4.0 commit and it may *theorically* lead to
a crash (even if that is very unlikely to occur).

Also Cc'ing trivial.

Thanks !

--
Greg

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] migration: fix bad string passed to error_report()
  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 15:47 ` Eric Blake
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Blake @ 2016-02-04 15:47 UTC (permalink / raw)
  To: Greg Kurz, Amit Shah, Juan Quintela; +Cc: qemu-devel

[-- 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 --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-04 15:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` Greg Kurz
2016-02-04 15:47 ` Eric Blake

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.