linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: linux-trace-devel@vger.kernel.org,
	Tzvetomir Stoyanov <tz.stoyanov@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Claire Jensen <cjense@google.com>
Cc: Ian Rogers <irogers@google.com>
Subject: [PATCH] libtraceevent: Workaround address sanitizer warnings.
Date: Wed,  9 Jun 2021 14:44:42 -0700	[thread overview]
Message-ID: <20210609214442.523914-1-irogers@google.com> (raw)

Reading a character 1 into an empty string (ie s = ""; ... = s[1]) triggers an
address sanitizer warning on reading of an unitilized value. Reorder the
code to avoid this.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 src/event-parse.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/event-parse.c b/src/event-parse.c
index 1217491..9915cb4 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -2039,7 +2039,7 @@ out_free:
 
 static int get_op_prio(char *op)
 {
-	if (!op[1]) {
+	if (strlen(op) == 1) {
 		switch (op[0]) {
 		case '~':
 		case '!':
@@ -2117,10 +2117,6 @@ process_op(struct tep_event *event, struct tep_print_arg *arg, char **tok)
 
 	if (arg->type == TEP_PRINT_OP && !arg->op.left) {
 		/* handle single op */
-		if (token[1]) {
-			do_warning_event(event, "bad op token %s", token);
-			goto out_free;
-		}
 		switch (token[0]) {
 		case '~':
 		case '!':
@@ -2132,6 +2128,10 @@ process_op(struct tep_event *event, struct tep_print_arg *arg, char **tok)
 			goto out_free;
 
 		}
+		if (token[1]) {
+			do_warning_event(event, "bad op token %s", token);
+			goto out_free;
+		}
 
 		/* make an empty left */
 		left = alloc_arg();
-- 
2.32.0.272.g935e593368-goog


                 reply	other threads:[~2021-06-09 21:45 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=20210609214442.523914-1-irogers@google.com \
    --to=irogers@google.com \
    --cc=cjense@google.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tz.stoyanov@gmail.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 NNTP newsgroup(s).