[PATCH BlueZ] advertising: Treat empty LocalName the same as omitting it

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

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

This treats empty LocalName ("") the same as omitting it so not name is
set in the advertising data since some D-Bus binding seems to have
problems to omit properties at runtime.

Fixes: https://github.com/bluez/bluez/issues/337
---
 src/advertising.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/advertising.c b/src/advertising.c
index 2110f17c9..ca23774ba 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -533,7 +533,15 @@ static bool parse_local_name(DBusMessageIter *iter,
 	dbus_message_iter_get_basic(iter, &name);
 
 	free(client->name);
-	client->name = strdup(name);
+
+	/* Treat empty string the same as omitting since there is no point on
+	 * adding a empty name as AD data as it just take space that could be
+	 * used for something else.
+	 */
+	if (name[0] != '\0')
+		client->name = strdup(name);
+	else
+		client->name = NULL;
 
 	return true;
 }
-- 
2.35.1




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux