OSDN Git Service

bt: fix sdp service name by removing NULL char
authorTimm Korte <timm.korte@gmail.com>
Mon, 15 May 2017 06:30:00 +0000 (08:30 +0200)
committerAndre Eisenbach <eisenbach@google.com>
Thu, 13 Jul 2017 18:39:47 +0000 (18:39 +0000)
commit557d20fd265ed96439e6635711d90ca208634792
tree7f8a02496892d4718cf7e19bd6bfe8f64bf4c815
parent1a55b43f5caf072aad235f6a1e496fecacce5a56
bt: fix sdp service name by removing NULL char

The Bluedroid stack uses a C string with terminating NULL char as a
service name. Since in BT, strings are TLV encoded (type, length,
value), this doesn't make sense.

Simple fix is to copy the string without the trailing NULL by
removing the "+1" after the strlen call when passing the string as
uint8_t array to the lower level functions.
The current behaviour keeps some older devices from being able to
connect to an Android providing a Serial Port profile due to having
the wrong service name (that is, including a NULL at the end instead
of the correct string).

Test: Checked against Linux BlueZ, which does not include this extra
null character.

Bug: 63665003
Change-Id: I6a43024ff89ac09e4b2d2e5cfb407b6e9323f0bd
Signed-off-by: Timm Korte <timm.korte@gmail.com>
(cherry picked from commit 625f798c696229b0cc58e5f85409fd029f987473)
btif/src/btif_sock_sdp.cc