[MERGED] libosmocore[master]: show bug in logging: out-of-bounds check should end with use...

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: out-of-bounds check should end with user categories
......................................................................


show bug in logging: out-of-bounds check should end with user categories

In the background osmo_log_info array, the user's logging categories are
enhanced by the library internal ones. So far logging category range checking
only checked for the larger array bounds, although passing a logging category
>= num_cat_user is already semantically unknown and should redirect to
DLGLOBAL.

Add a check to logging_test.c to show that this isn't happening. Instead of
DLGLOBAL, a logging category that happens to be at that index is queried.

The bug is confirmed by logging_test.err only showing "(e)" and not "(d)":
"(e)" is shown because the first category after the user ones happens to be
DLGLOBAL. "(d)" is omitted since it hits a category that's not on debug level.

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

Change-Id: I397278714018ee9a0ae5101515f31ddddf79c2ec
---
M tests/logging/logging_test.c
M tests/logging/logging_test.err
2 files changed, 5 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 3cc6c5b..5ef214d 100644
--- a/tests/logging/logging_test.c
+++ b/tests/logging/logging_test.c
@@ -113,9 +113,13 @@
 
 	/* Make sure out-of-bounds category maps to DLGLOBAL */
 	log_parse_category_mask(stderr_target, "DLGLOBAL,1");
+	/* For IDs out of bounds of the overall osmo_log_info array */
 	DEBUGP(osmo_log_info->num_cat + 1, "You should see this on DLGLOBAL (a)\n");
 	DEBUGP(osmo_log_info->num_cat + 100, "You should see this on DLGLOBAL (b)\n");
 	DEBUGP(osmo_log_info->num_cat, "You should see this on DLGLOBAL (c)\n");
+	/* For IDs out of bounds of the user categories part */
+	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");
 
 	return 0;
 }
diff --git a/tests/logging/logging_test.err b/tests/logging/logging_test.err
index 273a852..f4e9c1f 100644
--- a/tests/logging/logging_test.err
+++ b/tests/logging/logging_test.err
@@ -4,3 +4,4 @@
 DLGLOBAL You should see this on DLGLOBAL (a)
 DLGLOBAL You should see this on DLGLOBAL (b)
 DLGLOBAL You should see this on DLGLOBAL (c)
+DLGLOBAL You should see this on DLGLOBAL (e)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I397278714018ee9a0ae5101515f31ddddf79c2ec
Gerrit-PatchSet: 1
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