summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-04-09 01:35:02 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-04-09 17:57:15 +0200
commit2bcc873e93be0554694ade1f2ee6ef0ac8011d05 (patch)
treea21fc0d1af38f868c032a6fe018a3129656aa02e /src
parentd8f175cd2a1e134d0354341c9ac4d8e5c53171ea (diff)
osmo_fsm_inst_find_by_name(): guard against strcmp(NULL)
strcmp() *must not* be passed NULL pointers, or we hit: ../../../src/libosmocore/src/fsm.c:123:8: runtime error: null pointer passed as argument 2, which is declared to never be null ASAN:DEADLYSIGNAL (Or, alternatively, a segfault.) If any of the search string or an FSM instance's name string should be NULL, simply never match. Technically, an FSM should never have a NULL name, but a current bug actually allows this (pass NULL id to alloc), which will be addressed by an upcoming patch. To test for it, we need to first make sure this here doesn't segfault. Change-Id: I2e5f82c06d1a4727bd93e955366e3b62b2df1b32
Diffstat (limited to 'src')
-rw-r--r--src/fsm.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/fsm.c b/src/fsm.c
index c5256da5..88de0116 100644
--- a/src/fsm.c
+++ b/src/fsm.c
@@ -119,7 +119,12 @@ struct osmo_fsm_inst *osmo_fsm_inst_find_by_name(const struct osmo_fsm *fsm,
{
struct osmo_fsm_inst *fi;
+ if (!name)
+ return NULL;
+
llist_for_each_entry(fi, &fsm->instances, list) {
+ if (!fi->name)
+ continue;
if (!strcmp(name, fi->name))
return fi;
}