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-prev] [day] [month] [year] [list]
Message-Id: <20170811203809.120130-2-arunkaly@google.com>
Date:   Fri, 11 Aug 2017 13:38:09 -0700
From:   Arun Kalyanasundaram <arunkaly@...gle.com>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        linux-kernel@...r.kernel.org
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Arun Kalyanasundaram <arunkaly@...gle.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        "David S . Miller" <davem@...emloft.net>,
        SeongJae Park <sj38.park@...il.com>, davidcc@...gle.com,
        Stephane Eranian <eranian@...gle.com>,
        Arun Kalyanasundaram <arunkalys@...il.com>
Subject: [PATCH 1/1] perf script python: Garbled text in tracepoint fields

Pass the exact length of the string to is_printable_array instead of the
entire field size.

Signed-off-by: Arun Kalyanasundaram <arunkaly@...gle.com>
---
 tools/perf/util/scripting-engines/trace-event-python.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index c7187f067d31..45cc0c6635bb 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -601,6 +601,7 @@ static void python_process_tracepoint(struct perf_sample *sample,
 	for (field = event->format.fields; field; field = field->next) {
 		unsigned int offset, len;
 		unsigned long long val;
+		char *end_ptr = NULL;
 
 		if (field->flags & FIELD_IS_ARRAY) {
 			offset = field->offset;
@@ -612,8 +613,12 @@ static void python_process_tracepoint(struct perf_sample *sample,
 				len     = offset >> 16;
 				offset &= 0xffff;
 			}
-			if (field->flags & FIELD_IS_STRING &&
-			    is_printable_array(data + offset, len)) {
+			/* field may contain unused chars after the null char */
+			if (field->flags & FIELD_IS_STRING)
+				end_ptr = memchr(data + offset, '\0', len);
+			if (end_ptr &&
+			    is_printable_array(data + offset,
+				(int)(end_ptr - ((char *)data + offset)) + 1)) {
 				obj = PyString_FromString((char *) data + offset);
 			} else {
 				obj = PyByteArray_FromStringAndSize((const char *) data + offset, len);
-- 
2.14.0.434.g98096fd7a8-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ