From cf9d4572009110a840c6d1b51fe3032a5ce38e70 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 19 Feb 2018 16:07:38 -0500 Subject: [PATCH] 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 --- qemu/scripts/qapi.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qemu/scripts/qapi.py b/qemu/scripts/qapi.py index 43b5a3ac..5fa82a22 100644 --- a/qemu/scripts/qapi.py +++ b/qemu/scripts/qapi.py @@ -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 + "/"