summaryrefslogtreecommitdiff
path: root/gio
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2022-07-18 17:14:44 +0100
committerSimon McVittie <smcv@collabora.com>2022-07-18 17:53:40 +0100
commit3f532af65c98e4ba8426c53f26c9ee15d3692f9c (patch)
tree6da0151139686937c2461e7fa3260b4da7284eb7 /gio
parentb51e3ab09e39c590c65a7be6228ecfa48a6189f6 (diff)
downloadglib-3f532af65c98e4ba8426c53f26c9ee15d3692f9c.tar.gz
gdbusauth: Represent empty data block as DATA\r\n, with no space
This is an interoperability fix. The reference implementation of D-Bus treats "DATA\r\n" as equivalent to "DATA \r\n", but sd-bus does not, and only accepts the former. Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'gio')
-rw-r--r--gio/gdbusauth.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/gio/gdbusauth.c b/gio/gdbusauth.c
index d2ca41a20..89cbbf67c 100644
--- a/gio/gdbusauth.c
+++ b/gio/gdbusauth.c
@@ -807,11 +807,21 @@ _g_dbus_auth_run_client (GDBusAuth *auth,
{
gchar *data;
gsize data_len;
- gchar *encoded_data;
+
data = _g_dbus_auth_mechanism_client_data_send (mech, &data_len);
- encoded_data = _g_dbus_hexencode (data, data_len);
- s = g_strdup_printf ("DATA %s\r\n", encoded_data);
- g_free (encoded_data);
+
+ if (data_len == 0)
+ {
+ s = g_strdup ("DATA\r\n");
+ }
+ else
+ {
+ gchar *encoded_data = _g_dbus_hexencode (data, data_len);
+
+ s = g_strdup_printf ("DATA %s\r\n", encoded_data);
+ g_free (encoded_data);
+ }
+
g_free (data);
debug_print ("CLIENT: writing '%s'", s);
if (!g_data_output_stream_put_string (dos, s, cancellable, error))
@@ -1209,13 +1219,21 @@ _g_dbus_auth_run_server (GDBusAuth *auth,
gsize data_len;
data = _g_dbus_auth_mechanism_server_data_send (mech, &data_len);
+
if (data != NULL)
{
- gchar *encoded_data;
+ if (data_len == 0)
+ {
+ s = g_strdup ("DATA\r\n");
+ }
+ else
+ {
+ gchar *encoded_data = _g_dbus_hexencode (data, data_len);
+
+ s = g_strdup_printf ("DATA %s\r\n", encoded_data);
+ g_free (encoded_data);
+ }
- encoded_data = _g_dbus_hexencode (data, data_len);
- s = g_strdup_printf ("DATA %s\r\n", encoded_data);
- g_free (encoded_data);
g_free (data);
debug_print ("SERVER: writing '%s'", s);