]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
vici: Ignore NULL message in raise_event()
authorTobias Brunner <tobias@strongswan.org>
Tue, 6 Sep 2022 14:32:47 +0000 (16:32 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 20 Sep 2022 08:15:13 +0000 (10:15 +0200)
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

src/libcharon/plugins/vici/suites/test_event.c
src/libcharon/plugins/vici/vici_dispatcher.c

index 0c1121cba7870ff7b2f6d1da202b2fd719ba2df6..6b4ac9def2f761f55750e235ce49e4f654fd8452 100644 (file)
@@ -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));
index bc85d41d52d54c203d9181b3e9f64deb30bf75e9..818cd0e7cea94f0e22d42baa51b1d0505f5cba75 100644 (file)
@@ -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)