Work-around for broken MS device

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

 



Heya,

As seen in https://bugzilla.redhat.com/show_bug.cgi?id=450081
The Microsoft Wireless Notebook Presenter Mouse 8000 has its name in
ISO-8859-1 instead of UTF-8, as required by the BT spec.

I've implemented a small work-around. This isn't very invasive, IMO, as
we already do UTF-8 checks.

In my tests, this makes the mouse show up as:
Microsoft® Wireless Notebook Presenter Mouse 8000

Cheers
diff --git a/src/security.c b/src/security.c
index a61d75f..75908ba 100644
--- a/src/security.c
+++ b/src/security.c
@@ -600,8 +600,16 @@ static inline void remote_name_information(int dev, bdaddr_t *sba, void *ptr)
 		memcpy(name, evt->name, 248);
 		/* It's ok to cast end between const and non-const since
 		 * we know it points to inside of name which is non-const */
-		if (!g_utf8_validate(name, -1, (const char **) &end))
-			*end = '\0';
+		if (!g_utf8_validate(name, -1, (const char **) &end)) {
+			char *utf8_name;
+
+			utf8_name = g_convert(name, -1, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
+			if (utf8_name) {
+				memcpy(name, utf8_name, 248);
+				g_free(utf8_name);
+			} else
+				*end = '\0';
+		}
 		write_device_name(sba, &dba, name);
 	}
 

[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