Skip to content

Commit

Permalink
tools/kvm_stat: handle invalid regular expressions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stefan Raspl authored and Paolo Bonzini committed Dec 14, 2017
1 parent f3d11b0 commit 08e20a6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/kvm/kvm_stat/kvm_stat
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 08e20a6

Please sign in to comment.