From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X53MU-0006rO-Sf for qemu-devel@nongnu.org; Wed, 09 Jul 2014 21:41:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X53MQ-00075t-Gt for qemu-devel@nongnu.org; Wed, 09 Jul 2014 21:41:26 -0400 Message-ID: <53BDEF3D.1000309@redhat.com> Date: Wed, 09 Jul 2014 19:41:17 -0600 From: Eric Blake MIME-Version: 1.0 References: <1404915288-604-1-git-send-email-kwolf@redhat.com> In-Reply-To: <1404915288-604-1-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="8HrVIsgVOeOeH8lMnVJrGd9629SSaDds7" Subject: Re: [Qemu-devel] [PATCH for-2.1] test-string-output-visitor: Fix unterminated string List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, hutao@cn.fujitsu.com, mst@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --8HrVIsgVOeOeH8lMnVJrGd9629SSaDds7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 07/09/2014 08:14 AM, Kevin Wolf wrote: > Don't forget to add a terminating '\0' or the test case will be randoml= y > failing. The broken code was added in commit b4900c0e. Sorry, but I prefer this solution better: https://lists.gnu.org/archive/html/qemu-devel/2014-07/msg01595.html >=20 > Signed-off-by: Kevin Wolf > --- > tests/test-string-output-visitor.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/tests/test-string-output-visitor.c b/tests/test-string-out= put-visitor.c > index e89e43c..f2c427f 100644 > --- a/tests/test-string-output-visitor.c > +++ b/tests/test-string-output-visitor.c > @@ -201,11 +201,11 @@ static void test_visitor_out_enum(TestOutputVisit= orData *data, > visit_type_EnumOne(data->ov, &i, "unused", &err); > g_assert(!err); > =20 > - len =3D strlen(EnumOne_lookup[i]) + 2; > + len =3D strlen(EnumOne_lookup[i]) + 3; > str_human =3D g_malloc0(len); > str_human[0] =3D '"'; > strncpy(str_human + 1, EnumOne_lookup[i], strlen(EnumOne_looku= p[i])); > - str_human[len - 1] =3D '"'; > + str_human[len - 2] =3D '"'; Manually doing this when g_strdup_printf can do it as a one-liner is just lunacy. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --8HrVIsgVOeOeH8lMnVJrGd9629SSaDds7 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTve89AAoJEKeha0olJ0NqtcMH/2vAA3SpD4kLeypZpTxUBB4d n7oucJX6LaKLhj8T/9lK3hErXcJzOQW2GUFhUNNc9H+yCs2MI0KiQoUyn8nA0uLw fFuvYQG/mgoMZvGyZXrIydQCbcEykpmfj9sSy41VfDE+h+qh3cubqPa9psb4JWSO 7iAa9jvJNeYJvojJMpkcZ+E5RrbC0m52mdJkYwi2I8enenihVpiDJeoshzUVFkIn H9yPkxJFBhUBV1FqMebQWVjpuNrXVV6YhocOpHBHVxe2mnXcNLNexHU7GLiodDNR sRY+ekWKYGc7L1e/u6BrakG7i9uUNmbSj2SIujHFqhS0fg3yR9jhxYu8tpTLBNU= =idHC -----END PGP SIGNATURE----- --8HrVIsgVOeOeH8lMnVJrGd9629SSaDds7--