lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201015142959.GA18281@laptop>
Date:   Thu, 15 Oct 2020 17:30:04 +0300
From:   Fedor Tokarev <ftokarev@...il.com>
To:     rostedt@...dmis.org, acme@...hat.com
Cc:     linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        ftokarev@...il.com
Subject: [PATCH] tools: net: traceevent: Fix 'snprintf' return value check in
 'tep_filter_strerror'

'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@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ