From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHFKF-0000F8-DJ for qemu-devel@nongnu.org; Mon, 20 Jul 2015 13:58:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZHFKB-00065y-Cd for qemu-devel@nongnu.org; Mon, 20 Jul 2015 13:58:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49765) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHFKB-00065b-5T for qemu-devel@nongnu.org; Mon, 20 Jul 2015 13:57:59 -0400 References: <1435782155-31412-1-git-send-email-armbru@redhat.com> <1435782155-31412-6-git-send-email-armbru@redhat.com> From: Eric Blake Message-ID: <55AD36A1.6050405@redhat.com> Date: Mon, 20 Jul 2015 11:57:53 -0600 MIME-Version: 1.0 In-Reply-To: <1435782155-31412-6-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kOvVJeSoCRLQgwrQ1UF6trJ5se6PN7JCo" Subject: Re: [Qemu-devel] [PATCH RFC v2 05/47] qapi: Reject -p arguments that break qapi-event.py List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: kwolf@redhat.com, berto@igalia.com, mdroth@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --kOvVJeSoCRLQgwrQ1UF6trJ5se6PN7JCo Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 07/01/2015 02:21 PM, Markus Armbruster wrote: > qapi-event.py breaks when you ask for a funny prefix like '@'. > Protect it. Only possible from the command line (not triggered by our makefiles); but doesn't hurt. >=20 > Signed-off-by: Markus Armbruster > --- > scripts/qapi.py | 6 ++++++ > 1 file changed, 6 insertions(+) >=20 > diff --git a/scripts/qapi.py b/scripts/qapi.py > index 2bbc8ff..ea94ce5 100644 > --- a/scripts/qapi.py > +++ b/scripts/qapi.py > @@ -1003,6 +1003,12 @@ def parse_command_line(extra_options =3D "", ext= ra_long_options =3D []): > for oa in opts: > o, a =3D oa > if o in ("-p", "--prefix"): > + match =3D re.match('([A-Za-z_.-][A-Za-z0-9_.-]*)?', a) I can understand allowing a leading _, but why bother allowing a leading '.' or '-'? Those will get normalized to _, but in all honesty, no one should ever be doing that. I'd be just as happy with the shorter: match =3D re.match('([A-Za-z_][A-Za-z0-9_.-]*)?', a) > + if match.end() !=3D len(a): > + print >>sys.stderr, \ > + "%s: 'funny character '%s' in argument of -prefix"= \ 'qemu' is unusual for accepting -single-dash-long-opts; I don't think python getopts does the same by default. Please spell this error message --prefix. > + % (sys.argv[0], a[match.end()]) > + sys.exit(1) > prefix =3D a > elif o in ("-o", "--output-dir"): > output_dir =3D a + "/" >=20 With the second spelling fix, and optionally with the shorter regex, Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --kOvVJeSoCRLQgwrQ1UF6trJ5se6PN7JCo 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/ iQEcBAEBCAAGBQJVrTahAAoJEKeha0olJ0Nqi+gIAKkp+AeyG5n2P1ls9TWiygiO E/OQhjYZ4w95QBybxVZmw2SlPUnd1WgBx/ZRtBYR1/XjoycsKPzDh4u6f9GyvrxJ wmGbmkAG4p1aDQqvgOOeRm1JHRz6qQpWEkKmXZcM4v34TFDzDHB7hhygYkWRoMZb 1VSdPxWhLbfmbGPkjIwZfmjY1sfdVOYKNawi0SY8EwhlZwLaBL+9NVeDkXJrQYs+ XbPQ0BJTEQxoT9dew4/+B1FnV6BqPEnxBkec54Ligvi4eUPy+ROcFovUvZ4phFao MpMKzJzznYB621DXFFpiT6FbRY84ZA6XGDrLlrYfj/rf2MmPdzS7pNSIHAA+gGc= =Ct41 -----END PGP SIGNATURE----- --kOvVJeSoCRLQgwrQ1UF6trJ5se6PN7JCo--