OSDN Git Service

Fix for issues reported by Static analysis tool.
authorSatheesh Kumar Pallemoni <palsat@codeaurora.org>
Mon, 9 May 2016 12:43:05 +0000 (18:13 +0530)
committerLinux Build Service Account <lnxbuild@localhost>
Wed, 24 Aug 2016 14:09:31 +0000 (08:09 -0600)
Fixed issues in reported by static analysis tool.

Change-Id: I5a3ca9070ef21d2d86060b25f4282acf113a0987

bta/ag/bta_ag_main.c
bta/ag/bta_ag_rfc.c
bta/ag/bta_ag_sdp.c
bta/hf_client/bta_hf_client_main.c

index b96c9fe..62ca915 100644 (file)
@@ -849,7 +849,10 @@ void bta_ag_sm_execute(tBTA_AG_SCB *p_scb, UINT16 event, tBTA_AG_DATA *p_data)
     /* execute action functions */
     for (i = 0; i < BTA_AG_ACTIONS; i++)
     {
-        if ((action = state_table[event][i]) != BTA_AG_IGNORE)
+        /* Fix for below klockwork issue.
+         * Klockwork issue: Possible attempt to access element 33..255 of array 'bta_ag_action'
+         * whose size is 32 */
+        if (((action = state_table[event][i]) < BTA_AG_IGNORE) && (action >= 0))
         {
             (*bta_ag_action[action])(p_scb, p_data);
         }
index d3f2705..8d2ba26 100644 (file)
@@ -287,11 +287,12 @@ void bta_ag_start_servers(tBTA_AG_SCB *p_scb, tBTA_SERVICE_MASK services)
         {
             BTM_SetSecurityLevel(FALSE, "", bta_ag_sec_id[i], p_scb->serv_sec_mask,
                 BT_PSM_RFCOMM, BTM_SEC_PROTO_RFCOMM, bta_ag_cb.profile[i].scn);
-
+            /* Fix for below klockwork issue
+             * Array 'bta_ag_mgmt_cback_tbl' size is 3.
+             * Possible attempt to access element -1,3..USHRT_MAX-1 of array 'bta_ag_mgmt_cback_tbl'. */
             bta_ag_port_status =  RFCOMM_CreateConnection(bta_ag_uuid[i], bta_ag_cb.profile[i].scn,
                 TRUE, BTA_AG_MTU, (UINT8 *) bd_addr_any, &(p_scb->serv_handle[i]),
-                bta_ag_mgmt_cback_tbl[bta_ag_scb_to_idx(p_scb) - 1]);
-
+                bta_ag_mgmt_cback_tbl[(UINT16)(bta_ag_scb_to_idx(p_scb) - 1)]);
             if( bta_ag_port_status  == PORT_SUCCESS )
             {
                 bta_ag_setup_port(p_scb, p_scb->serv_handle[i]);
@@ -369,10 +370,12 @@ void bta_ag_rfc_do_open(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data)
 {
     BTM_SetSecurityLevel(TRUE, "", bta_ag_sec_id[p_scb->conn_service],
         p_scb->cli_sec_mask, BT_PSM_RFCOMM, BTM_SEC_PROTO_RFCOMM, p_scb->peer_scn);
-
+    /* Fix for below klockwork issue
+     * Array 'bta_ag_mgmt_cback_tbl' size is 3.
+     * Possible attempt to access element -1,3..USHRT_MAX-1 of array 'bta_ag_mgmt_cback_tbl' */
     if (RFCOMM_CreateConnection(bta_ag_uuid[p_scb->conn_service], p_scb->peer_scn,
             FALSE, BTA_AG_MTU, p_scb->peer_addr, &(p_scb->conn_handle),
-            bta_ag_mgmt_cback_tbl[bta_ag_scb_to_idx(p_scb) - 1]) == PORT_SUCCESS)
+            bta_ag_mgmt_cback_tbl[(UINT16)(bta_ag_scb_to_idx(p_scb) - 1)]) == PORT_SUCCESS)
     {
         bta_ag_setup_port(p_scb, p_scb->conn_handle);
         APPL_TRACE_DEBUG("bta_ag_rfc_do_open : conn_handle = %d", p_scb->conn_handle);
index edcb3ec..9c87211 100644 (file)
@@ -480,8 +480,11 @@ void bta_ag_do_disc(tBTA_AG_SCB *p_scb, tBTA_SERVICE_MASK service)
     if(db_inited)
     {
         /*Service discovery not initiated */
+        /*Fix for below Klockwork issue
+         *Array 'bta_ag_sdp_cback_tbl' size is 3
+         *Possible attempt to access element -1,3..USHRT_MAX-1 of array 'bta_ag_sdp_cback_tbl' */
         db_inited = SDP_ServiceSearchAttributeRequest(p_scb->peer_addr, p_scb->p_disc_db,
-                                      bta_ag_sdp_cback_tbl[bta_ag_scb_to_idx(p_scb) - 1]);
+                                      bta_ag_sdp_cback_tbl[(UINT16)(bta_ag_scb_to_idx(p_scb) - 1)]);
     }
 
     if(!db_inited)
index 8768797..6573952 100644 (file)
@@ -511,7 +511,7 @@ void bta_hf_client_sm_execute(UINT16 event, tBTA_HF_CLIENT_DATA *p_data)
     /* execute action functions */
     for (i = 0; i < BTA_HF_CLIENT_ACTIONS; i++)
     {
-        if ((action = state_table[event][i]) != BTA_HF_CLIENT_IGNORE)
+        if ((action = state_table[event][i]) < BTA_HF_CLIENT_IGNORE)
         {
             (*bta_hf_client_action[action])(p_data);
         }