[glib: 4/13] gdbusaddress: Require that transport names and keys are non-empty



commit 131ba66160e265cf319243e57933b43e6d98aee5
Author: Philip Withnall <withnall endlessm com>
Date:   Fri Mar 15 14:20:16 2019 +0000

    gdbusaddress: Require that transport names and keys are non-empty
    
    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 <withnall endlessm com>

 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]