[MERGED] libosmocore[master]: show bug in logging: log_set_category_filter on DL* categories

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Dec 13 14:56:28 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: show bug in logging: log_set_category_filter on DL* categories
......................................................................


show bug in logging: log_set_category_filter on DL* categories

Add a check to logging_test.c to show a bug: passing an internal DL* category
constant to log_set_category_filter() results in a negative array index and
undefined behavior. A sanitize build should catch this.

The bug is confirmed by the fact that logging_test.err stays the same
(hopefully) although a logging output should appear from this patch. The test
could as well segfault or anything else, it's a bit of a gamble.

This bug will be fixed along with the expectation in a subsequent patch.

Change-Id: Ie2da77c642a84cafc0f528985930697ec167183b
---
M tests/logging/logging_test.c
1 file changed, 6 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/tests/logging/logging_test.c b/tests/logging/logging_test.c
index 5ef214d..ce8aac8 100644
--- a/tests/logging/logging_test.c
+++ b/tests/logging/logging_test.c
@@ -121,5 +121,11 @@
 	DEBUGP(log_info.num_cat + 1, "You should see this on DLGLOBAL (d)\n");
 	DEBUGP(log_info.num_cat, "You should see this on DLGLOBAL (e)\n");
 
+	/* Check log_set_category_filter() with internal categories */
+	log_parse_category_mask(stderr_target, "DLGLOBAL,3");
+	DEBUGP(DLGLOBAL, "You should not see this (DLGLOBAL not on DEBUG)\n");
+	log_set_category_filter(stderr_target, DLGLOBAL, 1, LOGL_DEBUG);
+	DEBUGP(DLGLOBAL, "You should see this (DLGLOBAL on DEBUG)\n");
+
 	return 0;
 }

-- 
To view, visit https://gerrit.osmocom.org/1420
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie2da77c642a84cafc0f528985930697ec167183b
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list