linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] gdbus: Fix replying to messages marked with NOREPLY flag
@ 2018-01-28 13:50 Luiz Augusto von Dentz
  2018-01-31 11:33 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2018-01-28 13:50 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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
---
 gdbus/object.c | 17 ++++++++++-------
 1 file 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);
 }
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH BlueZ 1/2] gdbus: Fix replying to messages marked with NOREPLY flag
  2018-01-28 13:50 Luiz Augusto von Dentz
@ 2018-01-31 11:33 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2018-01-31 11:33 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org

Hi,

On Sun, Jan 28, 2018 at 11:50 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> When a sender flags a D-Bus message as not expecting a reply, it is
> against D-Bus policy to send a reply =E2=80=94 sending one can result in =
an
> error as reported in:
>
> https://bugzilla.kernel.org/show_bug.cgi?id=3D198453
> ---
>  gdbus/object.c | 17 ++++++++++-------
>  1 file 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(DBusMessag=
e *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(DBusMessag=
e *message,
>  {
>         DBusMessage *reply;
>
> +       /* Check if the message can be replied */
> +       if (dbus_message_get_no_reply(message))
> +               return NULL;
> +
>         reply =3D dbus_message_new_method_return(message);
>         if (reply =3D=3D NULL)
>                 return NULL;
> @@ -1571,14 +1579,9 @@ gboolean g_dbus_send_reply_valist(DBusConnection *=
connection,
>  {
>         DBusMessage *reply;
>
> -       reply =3D dbus_message_new_method_return(message);
> -       if (reply =3D=3D NULL)
> -               return FALSE;
> -
> -       if (dbus_message_append_args_valist(reply, type, args) =3D=3D FAL=
SE) {
> -               dbus_message_unref(reply);
> +       reply =3D g_dbus_create_reply_valist(message, type, args);
> +       if (!reply)
>                 return FALSE;
> -       }
>
>         return g_dbus_send_message(connection, reply);
>  }
> --
> 2.14.3


Pushed.



--=20
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH BlueZ 1/2] gdbus: Fix replying to messages marked with NOREPLY flag
@ 2018-02-05 12:47 Luiz Augusto von Dentz
  0 siblings, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2018-02-05 12:47 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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
---
 gdbus/object.c | 17 ++++++++++-------
 1 file 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);
 }
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-02-05 12:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-05 12:47 [PATCH BlueZ 1/2] gdbus: Fix replying to messages marked with NOREPLY flag Luiz Augusto von Dentz
  -- strict thread matches above, loose matches on Subject: below --
2018-01-28 13:50 Luiz Augusto von Dentz
2018-01-31 11:33 ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).