mirror of https://gerrit.osmocom.org/libosmocore
fix logging: log_set_category_filter() for internal DL* logging cats
In log_set_category_filter(), passing a negative index lead to memory corruption. Particularly dangerous since the internal logging categories have negative values. Fix: apply map_subsys() to interpret negative values as internal logging categories. As a side effect, out-of-bounds logging categories will be mapped to DLGLOBAL instead of being dropped. Fix the expectations in logging_test to match the fixed bug. While at it also guard against a NULL logging target. Change-Id: Ib0725b22bc39498c6b3970a61eb3339cf56d19f1
This commit is contained in:
parent
a4842afc83
commit
886d6fdec6
|
@ -577,8 +577,9 @@ void log_set_log_level(struct log_target *target, int log_level)
|
||||||
void log_set_category_filter(struct log_target *target, int category,
|
void log_set_category_filter(struct log_target *target, int category,
|
||||||
int enable, int level)
|
int enable, int level)
|
||||||
{
|
{
|
||||||
if (category >= osmo_log_info->num_cat)
|
if (!target)
|
||||||
return;
|
return;
|
||||||
|
category = map_subsys(category);
|
||||||
target->categories[category].enabled = !!enable;
|
target->categories[category].enabled = !!enable;
|
||||||
target->categories[category].loglevel = level;
|
target->categories[category].loglevel = level;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,3 +6,4 @@ DLGLOBAL You should see this on DLGLOBAL (b)
|
||||||
DLGLOBAL You should see this on DLGLOBAL (c)
|
DLGLOBAL You should see this on DLGLOBAL (c)
|
||||||
DLGLOBAL You should see this on DLGLOBAL (d)
|
DLGLOBAL You should see this on DLGLOBAL (d)
|
||||||
DLGLOBAL You should see this on DLGLOBAL (e)
|
DLGLOBAL You should see this on DLGLOBAL (e)
|
||||||
|
DLGLOBAL You should see this (DLGLOBAL on DEBUG)
|
||||||
|
|
Loading…
Reference in New Issue