This is an automated email from the ASF dual-hosted git repository.

kopyscinski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 10b3aa043ef7c2c023cd9418b5f35e40e07bb34f
Author: Krzysztof Kopyściński <[email protected]>
AuthorDate: Tue Aug 22 13:41:25 2023 +0200

    host/ble_att_svr.c: handle errors in ble_att_svr_rx_notify_multi
---
 nimble/host/src/ble_att_svr.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/nimble/host/src/ble_att_svr.c b/nimble/host/src/ble_att_svr.c
index eb91e3e1..aad64f68 100644
--- a/nimble/host/src/ble_att_svr.c
+++ b/nimble/host/src/ble_att_svr.c
@@ -2620,7 +2620,7 @@ ble_att_svr_rx_notify_multi(uint16_t conn_handle, 
uint16_t cid, struct os_mbuf *
 
     struct ble_att_tuple_list *req;
     uint16_t handle;
-    int rc;
+    int rc = 0;
     uint16_t pkt_len;
     struct os_mbuf *tmp;
     uint16_t attr_len;
@@ -2640,20 +2640,24 @@ ble_att_svr_rx_notify_multi(uint16_t conn_handle, 
uint16_t cid, struct os_mbuf *
         os_mbuf_adj(*rxom, 4);
 
         if (attr_len > BLE_ATT_ATTR_MAX_LEN) {
-            /*TODO Figure out what to do here */
-            break;
+            BLE_HS_LOG_ERROR("attr length (%d) > max (%d)",
+                             attr_len, BLE_ATT_ATTR_MAX_LEN);
+            rc = BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
+            goto done;
         }
 
         tmp = os_msys_get_pkthdr(attr_len, 0);
         if (!tmp) {
-            /*TODO Figure out what to do here */
-            break;
+            BLE_HS_LOG_ERROR("not enough resources, aborting");
+            rc = BLE_ATT_ERR_INSUFFICIENT_RES;
+            goto done;
         }
 
         rc = os_mbuf_appendfrom(tmp, *rxom, 0, attr_len);
         if (rc) {
-            /*TODO Figure out what to do here */
-            break;
+            BLE_HS_LOG_ERROR("not enough resources, aborting");
+            rc = BLE_ATT_ERR_INSUFFICIENT_RES;
+            goto done;
         }
 
         ble_gap_notify_rx_event(conn_handle, handle, tmp, 0);
@@ -2661,11 +2665,11 @@ ble_att_svr_rx_notify_multi(uint16_t conn_handle, 
uint16_t cid, struct os_mbuf *
         os_mbuf_adj(*rxom, attr_len);
         pkt_len = OS_MBUF_PKTLEN(*rxom);
     }
-
+done:
     os_mbuf_free_chain(*rxom);
     *rxom = NULL;
 
-    return 0;
+    return rc;
 }
 
 /**

Reply via email to