Blame SOURCES/oprofile-ppc_null_event.patch

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