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] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-11db4e29bb50442ecef2173f325b7be4e7790025@git.kernel.org>
Date:	Tue, 10 May 2016 13:35:44 -0700
From:	tip-bot for Masami Hiramatsu <tipbot@...or.com>
To:	linux-tip-commits@...r.kernel.org
Cc:	acme@...hat.com, mhiramat@...nel.org, mingo@...nel.org,
	namhyung@...nel.org, hpa@...or.com, tglx@...utronix.de,
	peterz@...radead.org, linux-kernel@...r.kernel.org
Subject: [tip:perf/core] perf pmu: Make pmu_formats_string to check return
 value of strbuf

Commit-ID:  11db4e29bb50442ecef2173f325b7be4e7790025
Gitweb:     http://git.kernel.org/tip/11db4e29bb50442ecef2173f325b7be4e7790025
Author:     Masami Hiramatsu <mhiramat@...nel.org>
AuthorDate: Tue, 10 May 2016 14:47:44 +0900
Committer:  Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Tue, 10 May 2016 11:57:52 -0300

perf pmu: Make pmu_formats_string to check return value of strbuf

Make pmu_formats_string() to check return value of strbuf APIs so that
it can detect errors in it.

Signed-off-by: Masami Hiramatsu <mhiramat@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Link: http://lkml.kernel.org/r/20160510054744.6158.37810.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
 tools/perf/util/pmu.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index bf34468..ddb0261 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -643,20 +643,20 @@ static int pmu_resolve_param_term(struct parse_events_term *term,
 static char *pmu_formats_string(struct list_head *formats)
 {
 	struct perf_pmu_format *format;
-	char *str;
-	struct strbuf buf;
+	char *str = NULL;
+	struct strbuf buf = STRBUF_INIT;
 	unsigned i = 0;
 
 	if (!formats)
 		return NULL;
 
-	strbuf_init(&buf, 0);
 	/* sysfs exported terms */
 	list_for_each_entry(format, formats, list)
-		strbuf_addf(&buf, i++ ? ",%s" : "%s",
-			    format->name);
+		if (strbuf_addf(&buf, i++ ? ",%s" : "%s", format->name) < 0)
+			goto error;
 
 	str = strbuf_detach(&buf, NULL);
+error:
 	strbuf_release(&buf);
 
 	return str;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ