[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 3/3] trace: Forbid dynamic field width in event format

From: Eric Blake
Subject: Re: [PATCH v2 3/3] trace: Forbid dynamic field width in event format
Date: Fri, 8 Nov 2019 10:07:38 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1

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):
+    _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

[Prev in Thread] Current Thread [Next in Thread]