]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
qapi: Reject -p arguments that break qapi-event.py
authorMarkus Armbruster <armbru@redhat.com>
Wed, 1 Jul 2015 11:13:54 +0000 (13:13 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 4 Sep 2015 13:47:13 +0000 (15:47 +0200)
qapi-event.py breaks when you ask for a funny prefix like '@'.
Protect it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
scripts/qapi.py

index ba11c54a9202c22847da1d0b2a5746423b28c1f6..bc3f4d3164e74835a24e5a52d5083890204954d7 100644 (file)
@@ -1003,6 +1003,12 @@ def parse_command_line(extra_options = "", extra_long_options = []):
     for oa in opts:
         o, a = oa
         if o in ("-p", "--prefix"):
+            match = re.match('([A-Za-z_.-][A-Za-z0-9_.-]*)?', a)
+            if match.end() != len(a):
+                print >>sys.stderr, \
+                    "%s: 'funny character '%s' in argument of --prefix" \
+                    % (sys.argv[0], a[match.end()])
+                sys.exit(1)
             prefix = a
         elif o in ("-o", "--output-dir"):
             output_dir = a + "/"