qapi: Reject -p arguments that break qapi-event.py

qapi-event.py breaks when you ask for a funny prefix like '@'.
Protect it.

Backports commit 1cf47a15f18312436c7fa2d97be5fbe6df0292f5 from qemu
This commit is contained in:
Markus Armbruster 2018-02-19 16:07:38 -05:00 committed by Lioncash
parent 2c3f6e4175
commit cf9d457200
No known key found for this signature in database
GPG Key ID: 4E3C3CC1031BA9C7

View File

@ -1001,6 +1001,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 + "/"