From 131ba66160e265cf319243e57933b43e6d98aee5 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 15 Mar 2019 14:20:16 +0000 Subject: [PATCH] gdbusaddress: Require that transport names and keys are non-empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The specification doesn’t explicitly say this, but it doesn’t say otherwise, and it would be pretty weird to have an empty transport name or key. Signed-off-by: Philip Withnall --- gio/gdbusaddress.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gio/gdbusaddress.c b/gio/gdbusaddress.c index 64c60dca9..756f1c0f3 100644 --- a/gio/gdbusaddress.c +++ b/gio/gdbusaddress.c @@ -451,6 +451,15 @@ _g_dbus_address_parse_entry (const gchar *address_entry, address_entry); goto out; } + else if (s == address_entry) + { + g_set_error (error, + G_IO_ERROR, + G_IO_ERROR_INVALID_ARGUMENT, + _("Transport name in address element “%s” must not be empty"), + address_entry); + goto out; + } transport_name = g_strndup (address_entry, s - address_entry); key_value_pairs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); @@ -474,6 +483,17 @@ _g_dbus_address_parse_entry (const gchar *address_entry, address_entry); goto out; } + else if (s == kv_pair) + { + g_set_error (error, + G_IO_ERROR, + G_IO_ERROR_INVALID_ARGUMENT, + _("Key/Value pair %d, “%s”, in address element “%s” must not have an empty key"), + n, + kv_pair, + address_entry); + goto out; + } key = g_uri_unescape_segment (kv_pair, s, NULL); value = g_uri_unescape_segment (s + 1, kv_pair + strlen (kv_pair), NULL);