Received: from eggs.gnu.org ([2001:4830:134:3::10]:47109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRbpi-0000Cr-Ti for qemu-devel@nongnu.org; Fri, 05 Feb 2016 03:33:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRbpd-0005Qg-UA for qemu-devel@nongnu.org; Fri, 05 Feb 2016 03:33:38 -0500 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:43027) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRbpd-0005QU-KL for qemu-devel@nongnu.org; Fri, 05 Feb 2016 03:33:33 -0500 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 5 Feb 2016 08:33:31 -0000 From: Greg Kurz Date: Fri, 05 Feb 2016 09:33:26 +0100 Message-ID: <20160205083201.2201.76109.stgit@bahia.huguette.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v2] migration: fix bad string passed to error_report() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah , Juan Quintela Cc: qemu-devel@nongnu.org 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 --- 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(-) diff --git a/migration/savevm.c b/migration/savevm.c index 954988d12130..4c361f4b7b6a 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;