gdbusdaemon: Fix error handling for filtering outgoing messages

If the filter function for an outgoing message fails to copy the
GDBusMessage, that failure was previously ignored, and GDBusMessage
methods could be called on a NULL instance.

Avoid that.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2019-04-12 16:55:17 +01:00
parent 2dac148299
commit 96aa2e34b3

View File

@ -1493,16 +1493,21 @@ filter_function (GDBusConnection *connection,
} }
else else
{ {
if (g_dbus_message_get_sender (message) == NULL ||
g_dbus_message_get_destination (message) == NULL)
{
message = copy_if_locked (message);
if (message == NULL)
{
g_warning ("Failed to copy outgoing message");
return NULL;
}
}
if (g_dbus_message_get_sender (message) == NULL) if (g_dbus_message_get_sender (message) == NULL)
{ g_dbus_message_set_sender (message, DBUS_SERVICE_NAME);
message = copy_if_locked (message);
g_dbus_message_set_sender (message, DBUS_SERVICE_NAME);
}
if (g_dbus_message_get_destination (message) == NULL) if (g_dbus_message_get_destination (message) == NULL)
{ g_dbus_message_set_destination (message, client->id);
message = copy_if_locked (message);
g_dbus_message_set_destination (message, client->id);
}
} }
return message; return message;