From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1admPW-0002Po-HN for qemu-devel@nongnu.org; Wed, 09 Mar 2016 17:16:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1admPV-0001Bp-Hh for qemu-devel@nongnu.org; Wed, 09 Mar 2016 17:16:54 -0500 References: <1457502997-30904-1-git-send-email-peterx@redhat.com> <1457502997-30904-3-git-send-email-peterx@redhat.com> From: Eric Blake Message-ID: <56E0A0CF.1080707@redhat.com> Date: Wed, 9 Mar 2016 15:16:47 -0700 MIME-Version: 1.0 In-Reply-To: <1457502997-30904-3-git-send-email-peterx@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="UgTKkaxwKV1xMkJUt2eTv80Jmdh6ofb1H" Subject: Re: [Qemu-devel] [PATCH 2/2] block/qapi: fix unbounded stack for dump_qdict List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Xu , qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, armbru@redhat.com, qemu-block@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --UgTKkaxwKV1xMkJUt2eTv80Jmdh6ofb1H Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 03/08/2016 10:56 PM, Peter Xu wrote: > Using heap instead of stack for better safety. >=20 > Signed-off-by: Peter Xu > --- > block/qapi.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Reviewed-by: Eric Blake >=20 > diff --git a/block/qapi.c b/block/qapi.c > index c4c2115..b798e35 100644 > --- a/block/qapi.c > +++ b/block/qapi.c > @@ -636,9 +636,8 @@ static void dump_qdict(fprintf_function func_fprint= f, void *f, int indentation, > for (entry =3D qdict_first(dict); entry; entry =3D qdict_next(dict= , entry)) { > QType type =3D qobject_type(entry->value); > bool composite =3D (type =3D=3D QTYPE_QDICT || type =3D=3D QTY= PE_QLIST); > - char key[strlen(entry->key) + 1]; > + char *key =3D g_malloc(strlen(entry->key) + 1); > int i; > - > /* replace dashes with spaces in key (variable) names */ > for (i =3D 0; entry->key[i]; i++) { > key[i] =3D entry->key[i] =3D=3D '-' ? ' ' : entry->key[i];= > @@ -650,6 +649,7 @@ static void dump_qdict(fprintf_function func_fprint= f, void *f, int indentation, > if (!composite) { > func_fprintf(f, "\n"); > } > + g_free(key); > } > } > =20 >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --UgTKkaxwKV1xMkJUt2eTv80Jmdh6ofb1H 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/ iQEcBAEBCAAGBQJW4KDPAAoJEKeha0olJ0Nq0tYH/jUi+PICynA97+Cjz53stbbm FzO9SXaT4Cmji/o9EHBMuY0PCiilkmAj468dVthdZPZdgHz3GA8z0/UrgevfNgbm K8l590QuhFRildF39J4BDD56G7xaOxLk2lmKjtJzzBj4c1/SSZ48xP3yP7XMFB37 u5kRQGrGlq8EqjhknVbUDDpVwPadlxA1q+MPw9JMC/oxxhFG/WMfatLVeD73cGYW Eq1Wcj3BPaR0TPxQbbtpKUSjHmw8suZkV72LVXI3dsFe38f/K/aVVTZYvMxuyY3b +PTkmqiM3oBiWDzLfDvkeoLden940e5I6GtxzxDmJ1YonnrBCqkZ13MgQSLK2hY= =Ox4N -----END PGP SIGNATURE----- --UgTKkaxwKV1xMkJUt2eTv80Jmdh6ofb1H--