[PATCH 2/2] service: Ignore invalid UTF-8 service name

Giuseppe Eletto <[email protected]> Wed, 8 Jul 2026 19:56:50 +0200
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
service_load() reads the WiFi service name from the per-service settings
file and stores it in service->name, which is later sent over D-Bus
in append_properties(). Like the tethering identifier and passphrase, a
corrupted settings file may contain a name that is not valid UTF-8, and
appending such a string to a D-Bus message aborts connmand.

Names obtained from a scan are already sanitized by create_name() in
gsupplicant, but the value loaded from storage is not. Validate it with
g_utf8_validate() and ignore it when it is not valid UTF-8.
---
 src/service.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/service.c b/src/service.c
index d5869b14..067ddd46 100644
--- a/src/service.c
+++ b/src/service.c
@@ -678,6 +678,14 @@ static int service_load(struct connman_service *service)
 
 			name = g_key_file_get_string(keyfile,
 					service->identifier, "Name", NULL);
+
+			if (name && !g_utf8_validate(name, -1, NULL)) {
+				connman_warn("Ignoring invalid Name for %s",
+						service->identifier);
+				g_free(name);
+				name = NULL;
+			}
+
 			if (name) {
 				g_free(service->name);
 				service->name = name;
-- 
2.50.1