tracetool: Forbid newline character in event format

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>
This commit is contained in:
Philippe Mathieu-Daudé 2024-06-06 12:39:43 +02:00 committed by Stefan Hajnoczi
parent 956f63f878
commit 4c2b6f3287

View File

@ -301,6 +301,8 @@ class Event(object):
if fmt.endswith(r'\n"'): if fmt.endswith(r'\n"'):
raise ValueError("Event format must not end with a newline " raise ValueError("Event format must not end with a newline "
"character") "character")
if '\\n' in fmt:
raise ValueError("Event format must not use new line character")
if len(fmt_trans) > 0: if len(fmt_trans) > 0:
fmt = [fmt_trans, fmt] fmt = [fmt_trans, fmt]