Message ID | 20240213155803.3159-2-iulia.tanasescu@nxp.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 7c49568a27580674e14f682fa0f6a7d555f8468c |
Headers | show |
Series | btdev: Fix set PA data array overflow | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
tedd_an/CheckPatch | success | CheckPatch PASS |
tedd_an/GitLint | success | Gitlint PASS |
tedd_an/BuildEll | success | Build ELL PASS |
tedd_an/BluezMake | success | Bluez Make PASS |
tedd_an/MakeCheck | success | Bluez Make Check PASS |
tedd_an/MakeDistcheck | success | Make Distcheck PASS |
tedd_an/CheckValgrind | success | Check Valgrind PASS |
tedd_an/CheckSmatch | warning | CheckSparse WARNING emulator/btdev.c:422:29: warning: Variable length array is used. |
tedd_an/bluezmakeextell | success | Make External ELL PASS |
tedd_an/IncrementalBuild | success | Incremental Build PASS |
tedd_an/ScanBuild | warning | ScanBuild: emulator/btdev.c:1086:10: warning: Although the value stored to 'conn' is used in the enclosing expression, the value is never actually read from 'conn' while ((conn = queue_find(dev->conns, match_handle, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ emulator/btdev.c:1369:24: warning: Access to field 'link' results in a dereference of a null pointer (loaded from variable 'conn') pending_conn_del(dev, conn->link->dev); ^~~~~~~~~~ emulator/btdev.c:1491:13: warning: Access to field 'dev' results in a dereference of a null pointer (loaded from variable 'conn') send_event(conn->dev, BT_HCI_EVT_AUTH_COMPLETE, &ev, sizeof(ev)); ^~~~~~~~~ 3 warnings generated. |
This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series: PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=825705 ---Test result--- Test Summary: CheckPatch PASS 0.31 seconds GitLint PASS 0.22 seconds BuildEll PASS 23.97 seconds BluezMake PASS 716.04 seconds MakeCheck PASS 11.60 seconds MakeDistcheck PASS 162.51 seconds CheckValgrind PASS 228.35 seconds CheckSmatch WARNING 328.25 seconds bluezmakeextell PASS 106.95 seconds IncrementalBuild PASS 658.05 seconds ScanBuild WARNING 947.23 seconds Details ############################## Test: CheckSmatch - WARNING Desc: Run smatch tool with source Output: emulator/btdev.c:422:29: warning: Variable length array is used. ############################## Test: ScanBuild - WARNING Desc: Run Scan Build Output: emulator/btdev.c:1086:10: warning: Although the value stored to 'conn' is used in the enclosing expression, the value is never actually read from 'conn' while ((conn = queue_find(dev->conns, match_handle, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ emulator/btdev.c:1369:24: warning: Access to field 'link' results in a dereference of a null pointer (loaded from variable 'conn') pending_conn_del(dev, conn->link->dev); ^~~~~~~~~~ emulator/btdev.c:1491:13: warning: Access to field 'dev' results in a dereference of a null pointer (loaded from variable 'conn') send_event(conn->dev, BT_HCI_EVT_AUTH_COMPLETE, &ev, sizeof(ev)); ^~~~~~~~~ 3 warnings generated. --- Regards, Linux Bluetooth
diff --git a/emulator/btdev.c b/emulator/btdev.c index 4ddbae403..4c9f5d181 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -5,7 +5,7 @@ * * Copyright (C) 2011-2012 Intel Corporation * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * * */ @@ -44,6 +44,8 @@ #define BIS_SIZE 3 #define CIG_SIZE 3 +#define MAX_PA_DATA_LEN 252 + #define has_bredr(btdev) (!((btdev)->features[4] & 0x20)) #define has_le(btdev) (!!((btdev)->features[4] & 0x40)) @@ -207,7 +209,7 @@ struct btdev { uint16_t le_pa_min_interval; uint16_t le_pa_max_interval; uint8_t le_pa_data_len; - uint8_t le_pa_data[31]; + uint8_t le_pa_data[MAX_PA_DATA_LEN]; struct bt_hci_cmd_le_pa_create_sync pa_sync_cmd; uint16_t le_pa_sync_handle; uint8_t big_handle; @@ -5210,9 +5212,13 @@ static int cmd_set_pa_data(struct btdev *dev, const void *data, { const struct bt_hci_cmd_le_set_pa_data *cmd = data; uint8_t status = BT_HCI_ERR_SUCCESS; + uint8_t data_len = cmd->data_len; + + if (data_len > MAX_PA_DATA_LEN) + data_len = MAX_PA_DATA_LEN; - dev->le_pa_data_len = cmd->data_len; - memcpy(dev->le_pa_data, cmd->data, 31); + dev->le_pa_data_len = data_len; + memcpy(dev->le_pa_data, cmd->data, data_len); cmd_complete(dev, BT_HCI_CMD_LE_SET_PA_DATA, &status, sizeof(status));