You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2025/11/24 10:35:52 UTC
(mynewt-nimble) 03/04: nimble/host/test: Fix buffer oveflows in HCI tests
This is an automated email from the ASF dual-hosted git repository.
janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit 30e2ee64255313b6c57dbfa741257a51b8e550b0
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Wed Nov 19 15:21:02 2025 +0100
nimble/host/test: Fix buffer oveflows in HCI tests
This are used for invalid tests and thus requires extra bytes for
invalid data.
---
nimble/host/test/src/ble_hs_hci_test.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/nimble/host/test/src/ble_hs_hci_test.c b/nimble/host/test/src/ble_hs_hci_test.c
index 8dd7c7777..7053a113a 100644
--- a/nimble/host/test/src/ble_hs_hci_test.c
+++ b/nimble/host/test/src/ble_hs_hci_test.c
@@ -47,7 +47,7 @@ TEST_CASE_SELF(ble_hs_hci_test_event_bad)
TEST_CASE_SELF(ble_hs_hci_test_rssi)
{
- uint8_t params[BLE_HCI_READ_RSSI_ACK_PARAM_LEN];
+ uint8_t params[BLE_HCI_READ_RSSI_ACK_PARAM_LEN + 1];
uint16_t opcode;
int8_t rssi;
int rc;
@@ -62,7 +62,8 @@ TEST_CASE_SELF(ble_hs_hci_test_rssi)
/* RSSI. */
params[2] = -8;
- ble_hs_test_util_hci_ack_set_params(opcode, 0, params, sizeof params);
+ ble_hs_test_util_hci_ack_set_params(opcode, 0, params,
+ BLE_HCI_READ_RSSI_ACK_PARAM_LEN);
rc = ble_hs_hci_util_read_rssi(1, &rssi);
TEST_ASSERT_FATAL(rc == 0);
@@ -71,18 +72,21 @@ TEST_CASE_SELF(ble_hs_hci_test_rssi)
/*** Failure: incorrect connection handle. */
put_le16(params + 0, 99);
- ble_hs_test_util_hci_ack_set_params(opcode, 0, params, sizeof params);
+ ble_hs_test_util_hci_ack_set_params(opcode, 0, params,
+ BLE_HCI_READ_RSSI_ACK_PARAM_LEN);
rc = ble_hs_hci_util_read_rssi(1, &rssi);
TEST_ASSERT(rc == BLE_HS_ECONTROLLER);
/*** Failure: params too short. */
- ble_hs_test_util_hci_ack_set_params(opcode, 0, params, sizeof params - 1);
+ ble_hs_test_util_hci_ack_set_params(opcode, 0, params,
+ BLE_HCI_READ_RSSI_ACK_PARAM_LEN - 1);
rc = ble_hs_hci_util_read_rssi(1, &rssi);
TEST_ASSERT(rc == BLE_HS_ECONTROLLER);
/*** Failure: params too long. */
- ble_hs_test_util_hci_ack_set_params(opcode, 0, params, sizeof params + 1);
+ ble_hs_test_util_hci_ack_set_params(opcode, 0, params,
+ BLE_HCI_READ_RSSI_ACK_PARAM_LEN + 1);
rc = ble_hs_hci_util_read_rssi(1, &rssi);
TEST_ASSERT(rc == BLE_HS_ECONTROLLER);