From: Greg Kurz Date: Fri, 5 Feb 2016 08:33:26 +0000 (+0100) Subject: migration: fix bad string passed to error_report() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=15d61692da651fc79b3fc40050b986c5a73055c0;p=people%2Fliuw%2Flibxenctrl-split%2Fqemu-xen.git 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. Reviewed-by: Amit Shah Signed-off-by: Greg Kurz Message-Id: <20160205083201.2201.76109.stgit@bahia.huguette.org> Signed-off-by: Amit Shah --- diff --git a/migration/savevm.c b/migration/savevm.c index 00be5fed8..94f289424 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'", + (int) state->len, state->name, current_name); return -EINVAL; } return 0;