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)
if (name[0] != '\0') {
stage = "service_name";
if (!SDP_AddAttribute(sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE,
- (uint32_t)(strlen(name) + 1), (uint8_t*)name))
+ (uint32_t)strlen(name), (uint8_t*)name))
goto error;
}