public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Fedor Tokarev <ftokarev@gmail.com>
To: rostedt@goodmis.org, acme@redhat.com
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	ftokarev@gmail.com
Subject: [PATCH] tools: net: traceevent: Fix 'snprintf' return value check in 'tep_filter_strerror'
Date: Thu, 15 Oct 2020 17:30:04 +0300	[thread overview]
Message-ID: <20201015142959.GA18281@laptop> (raw)

'snprintf' returns the number of characters which would have been written
if enough space had been available, excluding the terminating null byte.
Thus, the return value of 'buflen' means that the last character
was dropped.

Signed-off-by: Fedor Tokarev <ftokarev@gmail.com>
---
 tools/lib/traceevent/parse-filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index c271aee..dccdbf2 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1374,7 +1374,7 @@ int tep_filter_strerror(struct tep_event_filter *filter, enum tep_errno err,
 	if (strlen(filter->error_buffer) > 0) {
 		size_t len = snprintf(buf, buflen, "%s", filter->error_buffer);
 
-		if (len > buflen)
+		if (len >= buflen)
 			return -1;
 		return 0;
 	}
-- 
2.7.4


             reply	other threads:[~2020-10-15 14:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15 14:30 Fedor Tokarev [this message]
2020-10-15 15:12 ` AW: [PATCH] tools: net: traceevent: Fix 'snprintf' return value check in 'tep_filter_strerror' Walter Harms
2020-10-15 15:18   ` Steven Rostedt

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=20201015142959.GA18281@laptop \
    --to=ftokarev@gmail.com \
    --cc=acme@redhat.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.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