Skip to contentSkip to conversation

libtraceevent: Do not read non printable characters

PATCH New Steven Rostedt 1 participant 1 message Nov 23, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtraceevent: Do not read non printable characters

From: Cliff Wickman <[email protected]>

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

---
 src/event-parse.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/event-parse.c +2 -1
index 7063758..c3ea98e 100644
@@ -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--;
 
Signature · 1 line
2.31.1