From 48e906bceb8b4770bfcbaf481338c134658ce2c8 Mon Sep 17 00:00:00 2001 From: Jerome Marchand Date: Thu, 6 Jun 2024 17:38:25 +0200 Subject: [PATCH 11/15] libtracefs: my_yyinput() should return 0 when no data can be read YY_INPUT() is redefined in sqlhist.l and basically just call my_yyinput() to do the work. However, YY_INPUT is supposed to return YY_NULL (0 on Unix system) when no data can be read, not -1. This can cause an overflow error in the generated sqlhist-lex.c file. Have my_yyinput() returns zero when no buffer is found. Link: https://lore.kernel.org/linux-trace-devel/20240606153830.2666120-12-jmarchan@redhat.com Fixes: 25446407c5151 ("libtracefs: Added new API tracefs_sql()") Signed-off-by: Jerome Marchand Signed-off-by: Steven Rostedt (Google) --- src/tracefs-sqlhist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tracefs-sqlhist.c b/src/tracefs-sqlhist.c index c7b9eff..0f678c1 100644 --- a/src/tracefs-sqlhist.c +++ b/src/tracefs-sqlhist.c @@ -121,7 +121,7 @@ __hidden int my_yyinput(void *extra, char *buf, int max) struct sqlhist_bison *sb = extra; if (!sb || !sb->buffer) - return -1; + return 0; if (sb->buffer_idx + max > sb->buffer_size) max = sb->buffer_size - sb->buffer_idx; -- 2.45.2