From: Steven Rostedt <rostedt@goodmis.org>
To: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Cc: "Jerome Marchand" <jmarchan@redhat.com>
Subject: [PATCH] libtraceevent: Do not return a local stack pointer in get_field_str()
Date: Fri, 14 Jun 2024 15:54:56 -0400 [thread overview]
Message-ID: <20240614155456.092944eb@rorschach.local.home> (raw)
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
Jerome Marchand sent a patch with the description of:
The function get_field_str() can return a pointer to string on the
stack. Replace it by a global variable.
Fixes a RETURN_LOCAL error (CWE-562)
But made hex a global variable. Having a generic name "hex" as a global
variable in a library will cause a lot of issues. Just make it a static
variable, and then it can be used outside the function.
Link: https://lore.kernel.org/linux-trace-devel/20240607160542.46152-5-jmarchan@redhat.com/
Fixes: dee43d8067350 ("tools lib traceevent: Let filtering numbers by string use function names")
Reported-by: "Jerome Marchand" <jmarchan@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
src/parse-filter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/parse-filter.c b/src/parse-filter.c
index e448ee2b6799..75b84a0cc4ae 100644
--- a/src/parse-filter.c
+++ b/src/parse-filter.c
@@ -1704,8 +1704,8 @@ static const char *get_field_str(struct tep_filter_arg *arg, struct tep_record *
struct tep_handle *tep;
unsigned long long addr;
const char *val = NULL;
+ static char hex[64];
unsigned int size;
- char hex[64];
/* If the field is not a string convert it */
if (arg->str.field->flags & TEP_FIELD_IS_STRING) {
--
2.43.0
reply other threads:[~2024-06-14 19:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240614155456.092944eb@rorschach.local.home \
--to=rostedt@goodmis.org \
--cc=jmarchan@redhat.com \
--cc=linux-trace-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).