When parsing DBus messages to Domains.Configuration, remove all empty
strings from input. For example, sending
" example.com   foo.example.com " will result in
Domains.Configuration containing [ example.com, foo.example.com ],
rather than [ , example.com, , , foo.example.com, ].
---
 src/service.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/service.c b/src/service.c
index 3cf49a8..b14ddf7 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3372,6 +3372,10 @@ static DBusMessage *set_property(DBusConnection *conn,
                        const char *val;
                        dbus_message_iter_get_basic(&entry, &val);
                        dbus_message_iter_next(&entry);
+
+                       if (!val[0])
+                               continue;
+
                        if (str->len > 0)
                                g_string_append_printf(str, " %s", val);
                        else
@@ -3381,9 +3385,11 @@ static DBusMessage *set_property(DBusConnection *conn,
                searchdomain_remove_all(service);
                g_strfreev(service->domains);
 
-               if (str->len > 0)
-                       service->domains = g_strsplit_set(str->str, " ", 0);
-               else
+               if (str->len > 0) {
+                       char **domains = g_strsplit_set(str->str, " ", 0);
+                       domains = remove_empty_strings(domains);
+                       service->domains = domains;
+               } else
                        service->domains = NULL;
 
                g_string_free(str, TRUE);
-- 
2.1.0

_______________________________________________
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

Reply via email to