From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRM8Q-0002Xo-97 for qemu-devel@nongnu.org; Thu, 04 Feb 2016 10:48:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRM8N-0005pM-01 for qemu-devel@nongnu.org; Thu, 04 Feb 2016 10:47:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39414) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRM8M-0005pH-QT for qemu-devel@nongnu.org; Thu, 04 Feb 2016 10:47:50 -0500 References: <20160204092007.31588.66396.stgit@bahia.huguette.org> From: Eric Blake Message-ID: <56B3729E.7070601@redhat.com> Date: Thu, 4 Feb 2016 08:47:42 -0700 MIME-Version: 1.0 In-Reply-To: <20160204092007.31588.66396.stgit@bahia.huguette.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="mfW7f7oM4aQir0FFE9e5hLk5lXdc77u9T" Subject: Re: [Qemu-devel] [PATCH] migration: fix bad string passed to error_report() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz , Amit Shah , Juan Quintela Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --mfW7f7oM4aQir0FFE9e5hLk5lXdc77u9T Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/04/2016 02:20 AM, Greg Kurz wrote: > state->name does not contain a terminating '\0' and you may get: >=20 > Machine type received is 'pseries-2.3y=EF=BF=BD?' and local is 'pseries= -2.4' > load of migration failed: Invalid argument >=20 > Let's add a precision modifier to fix this. >=20 > Signed-off-by: Greg Kurz > --- > migration/savevm.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > 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, in= t version_id) > const char *current_name =3D MACHINE_GET_CLASS(current_machine)->n= ame; > =20 > if (strncmp(state->name, current_name, state->len) !=3D 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); =2E* 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'. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --mfW7f7oM4aQir0FFE9e5hLk5lXdc77u9T Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWs3KeAAoJEKeha0olJ0NqIMcH/0h2A96VKMmtLUGAyWsI6N+B fRXJs90pEwW/To+UoIiE0gWrHBAu37+NDJeKoWNVtvZ8eStMMNIpfoA/qLLNjUEB uh7JmqtH/YNWDSk8FuV7mBdWe3ww9457+PNiN7QNAaU4U+tl1pg5eH3R/M0H/D1U h3mK0VeLwRCNRkGaXoZiCE88Pt72R4UQK6Mf4/btA5tjq/PN01ENtlMvaJUfdlZW pdoKcOGU9FlMmUhxy8SHT0C8mNNkfKLBI4upaItB933KSwVbpLddGjYfVHoN/kuJ u+jsZfPw9y3dwnfXzHJl5rh31b6oEzrtm3BVWhEJBFB7h/F2MSKUeWchAdT97pw= =4b5r -----END PGP SIGNATURE----- --mfW7f7oM4aQir0FFE9e5hLk5lXdc77u9T--