Blame SOURCES/bz1018091-log-Filtering-by-function-and-file-must-match-ex.patch

76894c
From 9abb68637d6d448cccfa06daa05d9c5bf59f5d3e Mon Sep 17 00:00:00 2001
76894c
From: David Vossel <dvossel@redhat.com>
76894c
Date: Thu, 17 Oct 2013 21:44:12 -0500
76894c
Subject: [PATCH] Fix: log: Filtering by function and file must match exactly,
76894c
 no substring matches
76894c
76894c
---
76894c
 lib/log.c         | 4 ++--
76894c
 tests/check_log.c | 6 ++++--
76894c
 2 files changed, 6 insertions(+), 4 deletions(-)
76894c
76894c
diff --git a/lib/log.c b/lib/log.c
76894c
index 6d3435e..3b4d6bd 100644
76894c
--- a/lib/log.c
76894c
+++ b/lib/log.c
76894c
@@ -103,9 +103,9 @@ _cs_matches_filter_(struct qb_log_callsite *cs,
76894c
 			snprintf(token, 499, "%.*s", (int)(next - offset), offset);
76894c
 
76894c
 			if (type == QB_LOG_FILTER_FILE) {
76894c
-				match = (strstr(cs->filename, token) != NULL);
76894c
+				match = (strcmp(cs->filename, token) == 0) ? 1 : 0;
76894c
 			} else {
76894c
-				match = (strstr(cs->function, token) != NULL);
76894c
+				match = (strcmp(cs->function, token) == 0) ? 1 : 0;
76894c
 			}
76894c
 			if (!match && next[0] != 0) {
76894c
 				next++;
76894c
diff --git a/tests/check_log.c b/tests/check_log.c
76894c
index 3653b50..896bd7d 100644
76894c
--- a/tests/check_log.c
76894c
+++ b/tests/check_log.c
76894c
@@ -191,6 +191,7 @@ _test_logger(int32_t t,
76894c
 	test_buf[0] = '\0';
76894c
 	qb_log_target_format(t, cs, timestamp, msg, test_buf);
76894c
 	test_priority = cs->priority;
76894c
+
76894c
 	num_msgs++;
76894c
 }
76894c
 
76894c
@@ -282,6 +283,7 @@ START_TEST(test_log_basic)
76894c
 	rc = qb_log_ctl(t, QB_LOG_CONF_ENABLED, QB_TRUE);
76894c
 	ck_assert_int_eq(rc, 0);
76894c
 
76894c
+	/* captures last log */
76894c
 	memset(test_buf, 0, sizeof(test_buf));
76894c
 	test_priority = 0;
76894c
 	num_msgs = 0;
76894c
@@ -304,7 +306,7 @@ START_TEST(test_log_basic)
76894c
 	qb_log_filter_ctl(t, QB_LOG_FILTER_CLEAR_ALL,
76894c
 			  QB_LOG_FILTER_FILE, "*", LOG_TRACE);
76894c
 	qb_log_filter_ctl(t, QB_LOG_FILTER_ADD,
76894c
-			  QB_LOG_FILTER_FUNCTION, "log_it_please", LOG_WARNING);
76894c
+			  QB_LOG_FILTER_FUNCTION, "otherlogging,log_it_please,morelogging", LOG_WARNING);
76894c
 
76894c
 	num_msgs = 0;
76894c
 	qb_log(LOG_ERR, "try if you: log_it_please()");
76894c
@@ -336,7 +338,7 @@ START_TEST(test_log_basic)
76894c
 	qb_log_filter_ctl(t, QB_LOG_FILTER_CLEAR_ALL,
76894c
 			  QB_LOG_FILTER_FILE, "*", LOG_TRACE);
76894c
 	qb_log_filter_ctl(t, QB_LOG_FILTER_ADD,
76894c
-			  QB_LOG_FILTER_FILE, __FILE__, LOG_DEBUG);
76894c
+			  QB_LOG_FILTER_FILE, "fakefile.c,"__FILE__",otherfakefile", LOG_DEBUG);
76894c
 	/*
76894c
 	 * make sure we can pass in a null filename or function name.
76894c
 	 */
76894c
-- 
76894c
1.8.4.2
76894c