]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/qemu-xen.git/commitdiff
migration: fix bad string passed to error_report()
authorGreg Kurz <gkurz@linux.vnet.ibm.com>
Fri, 5 Feb 2016 08:33:26 +0000 (09:33 +0100)
committerAmit Shah <amit.shah@redhat.com>
Fri, 5 Feb 2016 13:39:51 +0000 (19:09 +0530)
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.

Reviewed-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Message-Id: <20160205083201.2201.76109.stgit@bahia.huguette.org>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
migration/savevm.c

index 00be5fed89735568e867f91e76e9ceb8f6d868c3..94f2894243ce518c86791a95e165207a90e24778 100644 (file)
@@ -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'",
+                     (int) state->len, state->name, current_name);
         return -EINVAL;
     }
     return 0;