[PATCH] libosmocore[master]: fix logging: out-of-bounds check should end with user catego...

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon Dec 12 15:09:58 UTC 2016


Review at  https://gerrit.osmocom.org/1419

fix logging: out-of-bounds check should end with user categories

To check category bounds, rather use num_cat_user, to redirect all semantically
unknown categories to DLGLOBAL.

Adjust logging_test expectations accordingly: "(d)" is now also shown.

Change-Id: I4a952b759f30d90fbfb81fedcfc56a8092ea18c1
---
M src/logging.c
M tests/logging/logging_test.err
2 files changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/19/1419/1

diff --git a/src/logging.c b/src/logging.c
index 2a8bfdc..35815ae 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -339,7 +339,7 @@
 	if (subsys < 0)
 		subsys = subsys_lib2index(subsys);
 
-	if (subsys < 0 || subsys >= osmo_log_info->num_cat)
+	if (subsys < 0 || subsys >= osmo_log_info->num_cat_user)
 		subsys = subsys_lib2index(DLGLOBAL);
 
 	OSMO_ASSERT(!(subsys < 0 || subsys >= osmo_log_info->num_cat));
diff --git a/tests/logging/logging_test.err b/tests/logging/logging_test.err
index f4e9c1f..4527d83 100644
--- a/tests/logging/logging_test.err
+++ b/tests/logging/logging_test.err
@@ -4,4 +4,5 @@
 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 (d)
 DLGLOBAL You should see this on DLGLOBAL (e)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4a952b759f30d90fbfb81fedcfc56a8092ea18c1
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list