[RFC Bluez] lib/sdb: Don't include NULL terminator in string's unitSize

From: Andrey Smirnov <hidden>
Date: 2019-10-19 06:54:02
Subsystem: library code, the rest · Maintainers: Andrew Morton, Linus Torvalds

HID report descriptors are 8-bit unsigned arrays (Data Element Type =
Text String (4), Data Element Size = array (5, 6, or 7)), so they are
parsed by extract_str(). Setting unitSize to "n + 1" in that case
results in NULL terminator of the string being passed as a part of a
HID report descriptor to the kernel. This causes harmless but
confusing "unknown main item tag 0x0" warning in dmesg. Change
unitSize to be "n" to avoid the problem.

The warning has been observed on the following hardware:

   - PowerA Wireless GameCube Style Controller for Nintendo

   - Sony DualShock 4 Controller connected via BT (works fine via USB)
---

Not sure if this is a right place to fix this or if I missed
something, hence the RFC tag. Maybe modifying extract_hid_desc_data()
would be more appropriate? Please let me know.

Thanks,
Andrey Smirnov

 lib/sdp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/sdp.c b/lib/sdp.c
index 84311eda1..6c0db825e 100644
--- a/lib/sdp.c
+++ b/lib/sdp.c
@@ -1211,7 +1211,7 @@ static sdp_data_t *extract_str(const void *p, int bufsize, int *len)
 	SDPDBG("Str : %s", s);
 
 	d->val.str = s;
-	d->unitSize = n + sizeof(uint8_t);
+	d->unitSize = n;
 	return d;
 }
 
-- 
2.21.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help