libtraceevent: Fix string parsing

The string parsing of tokens can be confused if the string has a backslash
at the end of the string. That is "\\\0" or \<nul>. The backslash will
skip the next character. If the next character is the end of the string,
it will read past the end of the string.

Check for end of buffer (less than or equal to 0), and if the next
character is the end of buffer, exit the loop regardless if the previous
character was a backslash.

Also fail the parsing of the event if the string is not terminated by the
quote that started it.

Link: https://lore.kernel.org/linux-trace-devel/20221219222630.54fc5bc5@gandalf.local.home

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 file changed