From: Steven Rostedt <rostedt@goodmis.org>
To: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Cc: Ross Zwisler <zwisler@google.com>
Subject: [PATCH] libtraceeval: Fix timestamp when vals is NULL
Date: Wed, 11 Oct 2023 18:23:51 -0400 [thread overview]
Message-ID: <20231011182351.098416bb@gandalf.local.home> (raw)
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
If traceeval_init() is passed NULL for vals, it can crash because he
teval->timestamp_idx is not updated and stays at zero. Then the check for
timestamp will iterate the NULL array of vals and crash.
Move the initialization of teval->timestamp_idx right after the teval is
allocated and do not depend on the val check to update it.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
src/histograms.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/histograms.c b/src/histograms.c
index 572f33eb3ac6..f77afc3a86a1 100644
--- a/src/histograms.c
+++ b/src/histograms.c
@@ -338,8 +338,6 @@ static int check_vals(struct traceeval *teval, struct traceeval_type *vals, int
vals[i].flags |= TRACEEVAL_FL_STAT;
vals[i].index = i;
}
- if (!ts_found)
- teval->timestamp_idx = -1;
return 0;
}
@@ -402,6 +400,8 @@ struct traceeval *traceeval_init_data_size(struct traceeval_type *keys,
goto fail;
}
+ teval->timestamp_idx = -1;
+
ret = check_keys(keys, nr_keys);
if (ret < 0)
goto fail_release;
--
2.42.0
reply other threads:[~2023-10-11 22:22 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=20231011182351.098416bb@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=zwisler@google.com \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).