Blame libtraceevent-Do-not-return-a-local-stack-pointer-in.patch

Jerome Marchand 7cf8e2
From 021da909bcbf657ceccbc1bcfa34b3d5c029be80 Mon Sep 17 00:00:00 2001
Jerome Marchand 7cf8e2
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
Jerome Marchand 7cf8e2
Date: Fri, 14 Jun 2024 15:54:56 -0400
Jerome Marchand 7cf8e2
Subject: [PATCH 7/7] libtraceevent: Do not return a local stack pointer in
Jerome Marchand 7cf8e2
 get_field_str()
Jerome Marchand 7cf8e2
Jerome Marchand 7cf8e2
Jerome Marchand sent a patch with the description of:
Jerome Marchand 7cf8e2
Jerome Marchand 7cf8e2
    The function get_field_str() can return a pointer to string on the
Jerome Marchand 7cf8e2
    stack. Replace it by a global variable.
Jerome Marchand 7cf8e2
Jerome Marchand 7cf8e2
    Fixes a RETURN_LOCAL error (CWE-562)
Jerome Marchand 7cf8e2
Jerome Marchand 7cf8e2
But made hex a global variable. Having a generic name "hex" as a global
Jerome Marchand 7cf8e2
variable in a library will cause a lot of issues. Just make it a static
Jerome Marchand 7cf8e2
variable, and then it can be used outside the function.
Jerome Marchand 7cf8e2
Jerome Marchand 7cf8e2
Link: https://lore.kernel.org/linux-trace-devel/20240607160542.46152-5-jmarchan@redhat.com/
Jerome Marchand 7cf8e2
Link: https://lore.kernel.org/linux-trace-devel/20240614155456.092944eb@rorschach.local.home
Jerome Marchand 7cf8e2
Jerome Marchand 7cf8e2
Fixes: dee43d8067350 ("tools lib traceevent: Let filtering numbers by string use function names")
Jerome Marchand 7cf8e2
Reported-by: "Jerome Marchand" <jmarchan@redhat.com>
Jerome Marchand 7cf8e2
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Jerome Marchand 7cf8e2
---
Jerome Marchand 7cf8e2
 src/parse-filter.c | 2 +-
Jerome Marchand 7cf8e2
 1 file changed, 1 insertion(+), 1 deletion(-)
Jerome Marchand 7cf8e2
Jerome Marchand 7cf8e2
diff --git a/src/parse-filter.c b/src/parse-filter.c
Jerome Marchand 7cf8e2
index e448ee2..75b84a0 100644
Jerome Marchand 7cf8e2
--- a/src/parse-filter.c
Jerome Marchand 7cf8e2
+++ b/src/parse-filter.c
Jerome Marchand 7cf8e2
@@ -1704,8 +1704,8 @@ static const char *get_field_str(struct tep_filter_arg *arg, struct tep_record *
Jerome Marchand 7cf8e2
 	struct tep_handle *tep;
Jerome Marchand 7cf8e2
 	unsigned long long addr;
Jerome Marchand 7cf8e2
 	const char *val = NULL;
Jerome Marchand 7cf8e2
+	static char hex[64];
Jerome Marchand 7cf8e2
 	unsigned int size;
Jerome Marchand 7cf8e2
-	char hex[64];
Jerome Marchand 7cf8e2
 
Jerome Marchand 7cf8e2
 	/* If the field is not a string convert it */
Jerome Marchand 7cf8e2
 	if (arg->str.field->flags & TEP_FIELD_IS_STRING) {
Jerome Marchand 7cf8e2
-- 
Jerome Marchand 7cf8e2
2.45.2
Jerome Marchand 7cf8e2