summaryrefslogtreecommitdiff
path: root/gdbus
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2018-01-28 11:22:26 -0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2018-01-31 08:42:47 -0200
commit5475f8bb2f794d5e4e1127651c71f0d7c3fcd319 (patch)
tree3de5428200e413e1915935f3bdc3e375cfc446b6 /gdbus
parentefffeeaa72bb2e38cb0ee1e98ab725da125ed714 (diff)
downloadbluez-5475f8bb2f794d5e4e1127651c71f0d7c3fcd319.tar.gz
gdbus: Fix replying to messages marked with NOREPLY flag
When a sender flags a D-Bus message as not expecting a reply, it is against D-Bus policy to send a reply — sending one can result in an error as reported in: https://bugzilla.kernel.org/show_bug.cgi?id=198453
Diffstat (limited to 'gdbus')
-rw-r--r--gdbus/object.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/gdbus/object.c b/gdbus/object.c
index 5c8ad7a55..e572c9f01 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1421,6 +1421,10 @@ DBusMessage *g_dbus_create_error_valist(DBusMessage *message, const char *name,
{
char str[1024];
+ /* Check if the message can be replied */
+ if (dbus_message_get_no_reply(message))
+ return NULL;
+
if (format)
vsnprintf(str, sizeof(str), format, args);
else
@@ -1449,6 +1453,10 @@ DBusMessage *g_dbus_create_reply_valist(DBusMessage *message,
{
DBusMessage *reply;
+ /* Check if the message can be replied */
+ if (dbus_message_get_no_reply(message))
+ return NULL;
+
reply = dbus_message_new_method_return(message);
if (reply == NULL)
return NULL;
@@ -1571,14 +1579,9 @@ gboolean g_dbus_send_reply_valist(DBusConnection *connection,
{
DBusMessage *reply;
- reply = dbus_message_new_method_return(message);
- if (reply == NULL)
- return FALSE;
-
- if (dbus_message_append_args_valist(reply, type, args) == FALSE) {
- dbus_message_unref(reply);
+ reply = g_dbus_create_reply_valist(message, type, args);
+ if (!reply)
return FALSE;
- }
return g_dbus_send_message(connection, reply);
}