diff mbox series

[5/5] tracetool: Forbid newline character in event format

Message ID 20240606103943.79116-6-philmd@linaro.org (mailing list archive)
State New, archived
Headers show
Series trace: Remove and forbid newline characters in event format | expand

Commit Message

Philippe Mathieu-Daudé June 6, 2024, 10:39 a.m. UTC
Events aren't designed to be multi-lines. Multiple events
can be used instead. Prevent that format using multi-lines
by forbidding the newline character.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 scripts/tracetool/__init__.py | 2 ++
 1 file changed, 2 insertions(+)

Comments

Daniel P. Berrangé June 6, 2024, 11:22 a.m. UTC | #1
On Thu, Jun 06, 2024 at 12:39:43PM +0200, Philippe Mathieu-Daudé wrote:
> Events aren't designed to be multi-lines. Multiple events
> can be used instead. Prevent that format using multi-lines
> by forbidding the newline character.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  scripts/tracetool/__init__.py | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

With regards,
Daniel
diff mbox series

Patch

diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 7237abe0e8..bc03238c0f 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -301,6 +301,8 @@  def build(line_str, lineno, filename):
         if fmt.endswith(r'\n"'):
             raise ValueError("Event format must not end with a newline "
                              "character")
+        if '\\n' in fmt:
+            raise ValueError("Event format must not use new line character")
 
         if len(fmt_trans) > 0:
             fmt = [fmt_trans, fmt]