From dd54709b9e1dbf5afb98db0807279e3712477b9b Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Sun, 13 Jan 2019 01:14:40 -0800 Subject: [PATCH] Fix handling of case where notification decode failure occurs I'm not sure whether this case can happen in the wild, but if artifically exercising the condition, I noticed it behaves poorly. Specifically: * The error_name parameter must be a valid D-Bus error name. It seems conventional to set this to "org.freedesktop.Notifications.Error". Without this change, the following error is thrown: CRITICAL: g_dbus_method_invocation_return_dbus_error: assertion 'error_name != NULL && g_dbus_is_name (error_name)' failed * Previously execution would continue even though the notification did not decode, causing essentially a null pointer exception later. Adds a return for this case. * With those two things fixed, this case seems relatively silent - "notify-send" invocations succeed even if the condition for the if is "true". So, I added a warning log to indicate that this case is occurring --- src/dbus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dbus.c b/src/dbus.c index 679a489..ee26a06 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -301,10 +301,12 @@ static void dbus_cb_Notify( { struct notification *n = dbus_message_to_notification(sender, parameters); if (!n) { + LOG_W("A notification failed to decode."); g_dbus_method_invocation_return_dbus_error( invocation, - "Cannot decode notification!", - ""); + FDN_IFAC".Error", + "Cannot decode notification!"); + return; } int id = queues_notification_insert(n);