]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
tools/kvm_stat: handle invalid regular expressions
authorStefan Raspl <stefan.raspl@de.ibm.com>
Mon, 11 Dec 2017 11:25:25 +0000 (12:25 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 14 Dec 2017 08:25:45 +0000 (09:25 +0100)
Passing an invalid regular expression on the command line results in a
traceback. Note that interactive specification of invalid regular
expressions is not affected
To reproduce, run "kvm_stat -f '*'".

Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/kvm/kvm_stat/kvm_stat

index 90f0445d78085f9f2d85315dd543f3c5c282fe7e..29c56f3a05dc1f97e131919b259d1df7c425351c 100755 (executable)
@@ -1521,6 +1521,13 @@ Press any other key to refresh statistics immediately.
                          callback=cb_guest_to_pid,
                          )
     (options, _) = optparser.parse_args(sys.argv)
+    try:
+        # verify that we were passed a valid regex up front
+        re.compile(options.fields)
+    except re.error:
+        sys.exit('Error: "' + options.fields + '" is not a valid regular '
+                 'expression')
+
     return options