Commit 30524fbd authored by Michael Catanzaro's avatar Michael Catanzaro

gdbusserver: properly escape all components of server address

!911 (comment 530668)
parent 16cdda5d
Pipeline #88882 passed with stages
in 25 minutes and 4 seconds
...@@ -769,27 +769,30 @@ try_unix (GDBusServer *server, ...@@ -769,27 +769,30 @@ try_unix (GDBusServer *server,
/* Fill out client_address if the connection attempt worked */ /* Fill out client_address if the connection attempt worked */
if (ret) if (ret)
{ {
const char *address_path;
char *escaped_path;
server->is_using_listener = TRUE; server->is_using_listener = TRUE;
address_path = g_unix_socket_address_get_path (G_UNIX_SOCKET_ADDRESS (address));
escaped_path = g_dbus_address_escape_value (address_path);
switch (g_unix_socket_address_get_address_type (G_UNIX_SOCKET_ADDRESS (address))) switch (g_unix_socket_address_get_address_type (G_UNIX_SOCKET_ADDRESS (address)))
{ {
case G_UNIX_SOCKET_ADDRESS_ABSTRACT: case G_UNIX_SOCKET_ADDRESS_ABSTRACT:
server->client_address = g_strdup_printf ("unix:abstract=%s", server->client_address = g_strdup_printf ("unix:abstract=%s", escaped_path);
g_unix_socket_address_get_path (G_UNIX_SOCKET_ADDRESS (address)));
break; break;
case G_UNIX_SOCKET_ADDRESS_PATH: case G_UNIX_SOCKET_ADDRESS_PATH:
{ server->client_address = g_strdup_printf ("unix:path=%s", escaped_path);
const char *address_path = g_unix_socket_address_get_path (G_UNIX_SOCKET_ADDRESS (address)); server->unix_socket_path = g_strdup (address_path);
server->client_address = g_strdup_printf ("unix:path=%s", address_path); break;
server->unix_socket_path = g_strdup (address_path);
break;
}
default: default:
g_assert_not_reached (); g_assert_not_reached ();
break; break;
} }
g_free (escaped_path);
} }
g_object_unref (address); g_object_unref (address);
} }
...@@ -881,6 +884,7 @@ try_tcp (GDBusServer *server, ...@@ -881,6 +884,7 @@ try_tcp (GDBusServer *server,
gsize bytes_written; gsize bytes_written;
gsize bytes_remaining; gsize bytes_remaining;
char *file_escaped; char *file_escaped;
char *host_escaped;
server->nonce = g_new0 (guchar, 16); server->nonce = g_new0 (guchar, 16);
for (n = 0; n < 16; n++) for (n = 0; n < 16; n++)
...@@ -920,11 +924,13 @@ try_tcp (GDBusServer *server, ...@@ -920,11 +924,13 @@ try_tcp (GDBusServer *server,
} }
if (!g_close (fd, error)) if (!g_close (fd, error))
goto out; goto out;
file_escaped = g_uri_escape_string (server->nonce_file, "/\\", FALSE); host_escaped = g_dbus_address_escape_value (host);
file_escaped = g_dbus_address_escape_value (server->nonce_file);
server->client_address = g_strdup_printf ("nonce-tcp:host=%s,port=%d,noncefile=%s", server->client_address = g_strdup_printf ("nonce-tcp:host=%s,port=%d,noncefile=%s",
host, host_escaped,
port_num, port_num,
file_escaped); file_escaped);
g_free (host_escaped);
g_free (file_escaped); g_free (file_escaped);
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment