diff mbox series

[11/15] libtracefs: my_yyinput() should return 0 when no data can be read

Message ID 20240606153830.2666120-12-jmarchan@redhat.com (mailing list archive)
State Accepted
Commit 48e906bceb8b4770bfcbaf481338c134658ce2c8
Headers show
Series libtracefs: fix misc issues found by static analysis | expand

Commit Message

Jerome Marchand June 6, 2024, 3:38 p.m. UTC
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.

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
---
 src/tracefs-sqlhist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

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;