tracetool: Forbid newline character in event format
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Thu, 6 Jun 2024 10:39:43 +0000 (12:39 +0200)
committerStefan Hajnoczi <stefanha@redhat.com>
Mon, 10 Jun 2024 17:05:27 +0000 (13:05 -0400)
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>
Acked-by: Mads Ynddal <mads@ynddal.dk>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-id: 20240606103943.79116-6-philmd@linaro.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
scripts/tracetool/__init__.py

index 7237abe0e8ca7a4353f938354221fc24ba776a93..bc03238c0faf489b65fd4edae001474bdc8a8fb5 100644 (file)
@@ -301,6 +301,8 @@ class Event(object):
         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]