mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-24 21:16:15 +01:00
gdbus: pass string length to hexencode()
This is necessary for it to be able to encode strings with embedded NUL characters. https://bugzilla.gnome.org/show_bug.cgi?id=794170
This commit is contained in:
parent
f7c0ff773e
commit
249330c388
@ -417,15 +417,15 @@ hexdecode (const gchar *str,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: take len */
|
|
||||||
static gchar *
|
static gchar *
|
||||||
hexencode (const gchar *str)
|
hexencode (const gchar *str,
|
||||||
|
gsize str_len)
|
||||||
{
|
{
|
||||||
guint n;
|
guint n;
|
||||||
GString *s;
|
GString *s;
|
||||||
|
|
||||||
s = g_string_new (NULL);
|
s = g_string_new (NULL);
|
||||||
for (n = 0; str[n] != '\0'; n++)
|
for (n = 0; n < str_len; n++)
|
||||||
{
|
{
|
||||||
gint val;
|
gint val;
|
||||||
gint upper_nibble;
|
gint upper_nibble;
|
||||||
@ -536,7 +536,7 @@ client_choose_mech_and_send_initial_response (GDBusAuth *auth,
|
|||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
|
|
||||||
initial_response_len = -1;
|
initial_response_len = 0;
|
||||||
initial_response = _g_dbus_auth_mechanism_client_initiate (mech,
|
initial_response = _g_dbus_auth_mechanism_client_initiate (mech,
|
||||||
&initial_response_len);
|
&initial_response_len);
|
||||||
#if 0
|
#if 0
|
||||||
@ -548,7 +548,7 @@ client_choose_mech_and_send_initial_response (GDBusAuth *auth,
|
|||||||
if (initial_response != NULL)
|
if (initial_response != NULL)
|
||||||
{
|
{
|
||||||
//g_printerr ("initial_response = '%s'\n", initial_response);
|
//g_printerr ("initial_response = '%s'\n", initial_response);
|
||||||
encoded = hexencode (initial_response);
|
encoded = hexencode (initial_response, initial_response_len);
|
||||||
s = g_strdup_printf ("AUTH %s %s\r\n",
|
s = g_strdup_printf ("AUTH %s %s\r\n",
|
||||||
_g_dbus_auth_mechanism_get_name (auth_mech_to_use_gtype),
|
_g_dbus_auth_mechanism_get_name (auth_mech_to_use_gtype),
|
||||||
encoded);
|
encoded);
|
||||||
@ -840,7 +840,7 @@ _g_dbus_auth_run_client (GDBusAuth *auth,
|
|||||||
gsize data_len;
|
gsize data_len;
|
||||||
gchar *encoded_data;
|
gchar *encoded_data;
|
||||||
data = _g_dbus_auth_mechanism_client_data_send (mech, &data_len);
|
data = _g_dbus_auth_mechanism_client_data_send (mech, &data_len);
|
||||||
encoded_data = hexencode (data);
|
encoded_data = hexencode (data, data_len);
|
||||||
s = g_strdup_printf ("DATA %s\r\n", encoded_data);
|
s = g_strdup_printf ("DATA %s\r\n", encoded_data);
|
||||||
g_free (encoded_data);
|
g_free (encoded_data);
|
||||||
g_free (data);
|
g_free (data);
|
||||||
@ -1215,7 +1215,7 @@ _g_dbus_auth_run_server (GDBusAuth *auth,
|
|||||||
{
|
{
|
||||||
gchar *encoded_data;
|
gchar *encoded_data;
|
||||||
|
|
||||||
encoded_data = hexencode (data);
|
encoded_data = hexencode (data, data_len);
|
||||||
s = g_strdup_printf ("DATA %s\r\n", encoded_data);
|
s = g_strdup_printf ("DATA %s\r\n", encoded_data);
|
||||||
g_free (encoded_data);
|
g_free (encoded_data);
|
||||||
g_free (data);
|
g_free (data);
|
||||||
|
Loading…
Reference in New Issue
Block a user