Blame SOURCES/oprofile-ppc_null_event.patch

0978ec
From 9d4345ab870c9990ae572eafc45fc999c23fa00b Mon Sep 17 00:00:00 2001
0978ec
From: William Cohen <wcohen@redhat.com>
0978ec
Date: Fri, 3 Aug 2018 10:10:12 -0400
0978ec
Subject: [PATCH] Handle empty event name spec gracefully for PPC
0978ec
0978ec
During testing Michael Petlan found that the giving an empty event
0978ec
name in the event spec to operf on PPC machines would cause operf
0978ec
crash.  Running the following following command would demonstrate
0978ec
this problem:
0978ec
0978ec
  operf -e : /bin/ls
0978ec
0978ec
The problem was traced to event_name in _handle_powerpc_event_spec
0978ec
function having a length of 0.  The strncmp using event_name in
0978ec
_handle_powerpc_event_spec would indicate a match and cause strncpy to
0978ec
be called to copy zero bytes. The zero length strncpy would crash
0978ec
operf.  Added a check to make ensure that the string is non-zero
0978ec
length.
0978ec
0978ec
Signed-off-by: William Cohen <wcohen@redhat.com>
0978ec
---
0978ec
 libpe_utils/op_pe_utils.cpp | 2 +-
0978ec
 1 file changed, 1 insertion(+), 1 deletion(-)
0978ec
0978ec
diff --git a/libpe_utils/op_pe_utils.cpp b/libpe_utils/op_pe_utils.cpp
0978ec
index f9638c77..2cae7840 100644
0978ec
--- a/libpe_utils/op_pe_utils.cpp
0978ec
+++ b/libpe_utils/op_pe_utils.cpp
0978ec
@@ -588,7 +588,7 @@ static string _handle_powerpc_event_spec(string event_spec)
0978ec
 		}
0978ec
 		if (line[0] == ' ' || line[0] == '\t')
0978ec
 			continue;
0978ec
-		if (!strncmp(line, event_name, evt_name_len)) {
0978ec
+		if (evt_name_len && !strncmp(line, event_name, evt_name_len)) {
0978ec
 			// Found a potential match.  Check if it's a perfect match.
0978ec
 			string save_event_name = event_name;
0978ec
 			size_t full_evt_len = index(line, ':') - line;
0978ec
-- 
0978ec
2.17.1
0978ec