Linux-Trace-Devel Archive on lore.kernel.org
 help / Atom feed
* [PATCH] tools/lib/traceevent: fix a buffer overrun
@ 2019-01-25 10:20 Tzvetomir Stoyanov
  0 siblings, 0 replies; 1+ messages in thread
From: Tzvetomir Stoyanov @ 2019-01-25 10:20 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel, mikesart

Fix a buffer overrun in arg_eval() function in
traceevent library. The min value of long long
is -9223372036854775808, it needs at least
21 bytes to be printed as a string.

Reported-by: Michael Sartain <mikesart@fastmail.com>
Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
---
 tools/lib/traceevent/event-parse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index f6c926467fa3..ff065796ace3 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -2472,7 +2472,7 @@ static int arg_num_eval(struct tep_print_arg *arg, long long *val)
 static char *arg_eval (struct tep_print_arg *arg)
 {
 	long long val;
-	static char buf[20];
+	static char buf[21];
 
 	switch (arg->type) {
 	case TEP_PRINT_ATOM:
@@ -2482,7 +2482,7 @@ static char *arg_eval (struct tep_print_arg *arg)
 	case TEP_PRINT_OP:
 		if (!arg_num_eval(arg, &val))
 			break;
-		sprintf(buf, "%lld", val);
+		snprintf(buf, 21, "%lld", val);
 		return buf;
 
 	case TEP_PRINT_NULL:
-- 
2.20.1


^ permalink raw reply	[flat|nested] 1+ messages in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-25 10:20 [PATCH] tools/lib/traceevent: fix a buffer overrun Tzvetomir Stoyanov

Linux-Trace-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-trace-devel/0 linux-trace-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-trace-devel linux-trace-devel/ https://lore.kernel.org/linux-trace-devel \
		linux-trace-devel@vger.kernel.org linux-trace-devel@archiver.kernel.org
	public-inbox-index linux-trace-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-trace-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox