On 11/8/19 8:40 AM, Philippe Mathieu-Daudé wrote:
Since not all trace backends support dynamic field width in
format (dtrace via stap does not), forbid them.

Add a check to refuse field width in new formats:


+++ b/scripts/tracetool/__init__.py
@@ -206,6 +206,7 @@ class Event(object):
                        "\s*"
                        "(?:(?:(?P<fmt_trans>\".+),)?\s*(?P<fmt>\".+))?"
                        "\s*")
+    _DFWRE = re.compile(".*(%0?\*).*")

The use of leading and trailing .* is pointless if the RE itself is used unanchored and where you only care if the () matched.

This doesn't catch all valid uses of * in a printf format. Better might be something like:

_DFWRE = re.compile("%[\d\.\- +#']*\*")

which matches only if there is a %, any number of characters that can form a printf flag, as well as a numeric field width but dynamic precision.


+        if Event._DFWRE.match(fmt):
+            raise ValueError("Event format must not contain field width '%*'")
if len(fmt_trans) > 0:
              fmt = [fmt_trans, fmt]


--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


Reply via email to