mirror of https://gerrit.osmocom.org/libosmocore
fix logging: also catch first out-of-bounds logging cat
In map_subsys(), fix the '>' condition to '>=' for array bounds checking. Also make the bounds checking more strict: after both invocations of subsys_lib2index(), re-check validity of the array index. If the final index is still wrong, which should never happen, exit by assertion. Change-Id: I7ca1a1d47724e40350f1c4dfebe90bad01c965f9
This commit is contained in:
parent
a280b82f8e
commit
ca13574ba4
|
@ -339,9 +339,11 @@ static inline int map_subsys(int subsys)
|
|||
if (subsys < 0)
|
||||
subsys = subsys_lib2index(subsys);
|
||||
|
||||
if (subsys > osmo_log_info->num_cat)
|
||||
if (subsys < 0 || subsys >= osmo_log_info->num_cat)
|
||||
subsys = subsys_lib2index(DLGLOBAL);
|
||||
|
||||
OSMO_ASSERT(!(subsys < 0 || subsys >= osmo_log_info->num_cat));
|
||||
|
||||
return subsys;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,3 +3,4 @@ DCC You should see this
|
|||
DRLL You should see this
|
||||
DLGLOBAL You should see this on DLGLOBAL (a)
|
||||
DLGLOBAL You should see this on DLGLOBAL (b)
|
||||
DLGLOBAL You should see this on DLGLOBAL (c)
|
||||
|
|
Loading…
Reference in New Issue