Skip to contentSkip to conversation

migration: fix bad string passed to error_report()

PATCH New Greg Kurz 1 participant 1 message Feb 5, 2016

lore
Share & tools
lore

Greg Kurz

author
#0 lore raw

PATCH v2 1/1 migration: fix bad string passed to error_report()

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.

---
v2: - added Amit's R-b tag
- added (int) cast to avoid warnings on 32-bit cygwin

---
 migration/savevm.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
migration/savevm.c +2 -2
index 954988d12130..4c361f4b7b6a 100644
@@ -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;