diff mbox series

libtraceevent: Do not read non printable characters

Message ID 20211123171003.7e24cd37@gandalf.local.home (mailing list archive)
State Accepted
Commit d0fbd046a090834ac1ee69d45f321d7fa2a5c9b4
Headers show
Series libtraceevent: Do not read non printable characters | expand

Commit Message

Steven Rostedt Nov. 23, 2021, 10:10 p.m. UTC
From: Cliff Wickman <cliff.wickman@hpe.com>

libtraceevent is getting into a loop if the trace.dat file contains
corrupted strings ending in non-printable characters instead of quotes.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215121
Signed-off-by: Cliff Wickman <cliff.wickman@hpe.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 src/event-parse.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/event-parse.c b/src/event-parse.c
index 7063758..c3ea98e 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -1246,7 +1246,8 @@  static enum tep_event_type __read_token(char **tok)
 			/* the '\' '\' will cancel itself */
 			if (ch == '\\' && last_ch == '\\')
 				last_ch = 0;
-		} while (ch != quote_ch || last_ch == '\\');
+			/* Break out if the file is corrupted and giving non print chars */
+		} while ((ch != quote_ch && isprint(ch)) || last_ch == '\\');
 		/* remove the last quote */
 		i--;