summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGanesh Ganapathi Batta <ganeshg@broadcom.com>2012-08-23 10:10:46 -0700
committerMatthew Xie <mattx@google.com>2012-08-25 01:13:17 -0700
commitbe7063ce21ac1e2f67d489c29a1e979dc3d8f075 (patch)
tree34927d60747d3e0221a10b2053a9a2b1fbae5deb
parent8ea28806bf5443ebf2e3449f810961ddbcf26d01 (diff)
downloadexternal_bluetooth_bluedroid-be7063ce21ac1e2f67d489c29a1e979dc3d8f075.zip
external_bluetooth_bluedroid-be7063ce21ac1e2f67d489c29a1e979dc3d8f075.tar.gz
external_bluetooth_bluedroid-be7063ce21ac1e2f67d489c29a1e979dc3d8f075.tar.bz2
Null terminate Local name before sending to stack
Ensure that Local name string is always Null terminated when sending it to BT stack from BTIF layer Bug:7027639 Change-Id: I319642d6073d4178bd34ca82431c4bda16270474
-rwxr-xr-x[-rw-r--r--]btif/src/btif_core.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/btif/src/btif_core.c b/btif/src/btif_core.c
index 666efa7..032ddf0 100644..100755
--- a/btif/src/btif_core.c
+++ b/btif/src/btif_core.c
@@ -1108,6 +1108,8 @@ bt_status_t btif_set_adapter_property(const bt_property_t *property)
btif_storage_req_t req;
bt_status_t status = BT_STATUS_SUCCESS;
int storage_req_id = BTIF_CORE_STORAGE_NOTIFY_STATUS; /* default */
+ char bd_name[BTM_MAX_LOC_BD_NAME_LEN +1];
+ UINT16 name_len = 0;
BTIF_TRACE_EVENT3("btif_set_adapter_property type: %d, len %d, 0x%x",
property->type, property->len, property->val);
@@ -1119,9 +1121,14 @@ bt_status_t btif_set_adapter_property(const bt_property_t *property)
{
case BT_PROPERTY_BDNAME:
{
- BTIF_TRACE_EVENT1("set property name : %s", (char *)property->val);
+ name_len = property->len > BTM_MAX_LOC_BD_NAME_LEN ? BTM_MAX_LOC_BD_NAME_LEN:
+ property->len;
+ memcpy(bd_name,property->val, name_len);
+ bd_name[name_len] = '\0';
- BTA_DmSetDeviceName((char *)property->val);
+ BTIF_TRACE_EVENT1("set property name : %s", (char *)bd_name);
+
+ BTA_DmSetDeviceName((char *)bd_name);
storage_req_id = BTIF_CORE_STORAGE_ADAPTER_WRITE;
}