From: Tobias Brunner Date: Tue, 6 Sep 2022 14:32:47 +0000 (+0200) Subject: vici: Ignore NULL message in raise_event() X-Git-Tag: 5.9.8dr4~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f21ef43b0c74e59710ec5fa4d612d4174bf3592d;p=thirdparty%2Fstrongswan.git vici: Ignore NULL message in raise_event() There are a lot of calls like this: this->dispatcher->raise_event(this->dispatcher, "...", 0, b->finalize(b)); However, if finalize() fails, e.g. because a previous call to add() failed due to the size limit, it returns NULL. This then caused a segmentation fault in raise_event() when it interacted with that value. Closes strongswan/strongswan#1278 --- diff --git a/src/libcharon/plugins/vici/suites/test_event.c b/src/libcharon/plugins/vici/suites/test_event.c index 0c1121cba7..6b4ac9def2 100644 --- a/src/libcharon/plugins/vici/suites/test_event.c +++ b/src/libcharon/plugins/vici/suites/test_event.c @@ -60,6 +60,9 @@ START_TEST(test_event) ck_assert(vici_register(conn, "test", event_cb, &count) == 0); ck_assert(vici_register(conn, "nonexistent", event_cb, &count) != 0); + /* should just get ignored */ + dispatcher->raise_event(dispatcher, "test", 0, NULL); + dispatcher->raise_event(dispatcher, "test", 0, vici_message_create_from_args( VICI_KEY_VALUE, "key1", chunk_from_str("value1"), VICI_END)); diff --git a/src/libcharon/plugins/vici/vici_dispatcher.c b/src/libcharon/plugins/vici/vici_dispatcher.c index bc85d41d52..818cd0e7ce 100644 --- a/src/libcharon/plugins/vici/vici_dispatcher.c +++ b/src/libcharon/plugins/vici/vici_dispatcher.c @@ -497,6 +497,11 @@ METHOD(vici_dispatcher_t, raise_event, void, event_t *event; u_int *current; + if (!message) + { + return; + } + this->mutex->lock(this->mutex); event = this->events->get(this->events, name); if (event)