From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V08Nr-0004vZ-N1 for qemu-devel@nongnu.org; Fri, 19 Jul 2013 06:58:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V08Np-0000QQ-8z for qemu-devel@nongnu.org; Fri, 19 Jul 2013 06:57:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60515) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V08No-0000Q6-Uv for qemu-devel@nongnu.org; Fri, 19 Jul 2013 06:57:57 -0400 Message-ID: <51E91BAF.4050903@redhat.com> Date: Fri, 19 Jul 2013 04:57:51 -0600 From: Eric Blake MIME-Version: 1.0 References: <1374201401-11244-1-git-send-email-p.pawit@gmail.com> In-Reply-To: <1374201401-11244-1-git-send-email-p.pawit@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="v7TEvxPuGXArXnHfSeAe9kka5eKdgbqFh" Subject: Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pawit Pornkitprasan Cc: Ryousei Takano , qemu-devel@nongnu.org, Juan Quintela This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --v7TEvxPuGXArXnHfSeAe9kka5eKdgbqFh Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 07/18/2013 08:36 PM, Pawit Pornkitprasan wrote: > The qmp_migrate method uses the 'blk' and 'inc' parameter without > checking if they're valid or not (they may be uninitialized if > command is received via QMP) >=20 > Signed-off-by: Pawit Pornkitprasan > --- > migration.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Reviewed-by: Eric Blake However, wouldn't it be nice if we improved the qapi generator to guarantee a sane default value for optional parameters, even when has_value is false? >=20 > diff --git a/migration.c b/migration.c > index 9f5a423..f3d1ff7 100644 > --- a/migration.c > +++ b/migration.c > @@ -385,8 +385,8 @@ void qmp_migrate(const char *uri, bool has_blk, boo= l blk, > MigrationParams params; > const char *p; > =20 > - params.blk =3D blk; > - params.shared =3D inc; > + params.blk =3D has_blk && blk; > + params.shared =3D has_inc && inc; > =20 > if (s->state =3D=3D MIG_STATE_ACTIVE) { > error_set(errp, QERR_MIGRATION_ACTIVE); >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --v7TEvxPuGXArXnHfSeAe9kka5eKdgbqFh Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJR6RuvAAoJEKeha0olJ0Nqo3AH/3o0+PfGxPkTwbHoS5ITute2 4lmGd7AT+IC2s7HB3z1gwuXRk3nGK/2k/uLKMcQBbnHIYQNPq0do58F3FhRQFKyH gYSL2th9504L1uzLNbmGovEvwQO7tQe5uDfU3GtslKLrmapRoY8YJpY1P7aQndtQ ZCm/6KYR0934LTjXGoY51uCKHUY9UyB02K0erVtjzOdvp/Av3fSao3HbRTfBi7A/ BY2BgZxw/2yZsUnkDojzr1RpxGwnL0P9VV9DGcf9U+AsgwxUSwgQQoQtGToXSF7k gtlnjFFZFv5JdhARkzQx0ReMbiCgmkXvwBCVwt5POtgJvRF0sOPQ/p5KpNsfEWo= =hSRy -----END PGP SIGNATURE----- --v7TEvxPuGXArXnHfSeAe9kka5eKdgbqFh--