Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Coverity CID :218728] Out-of-bounds access in subsys/bluetooth/host/gatt.c #32399

Closed
zephyrbot opened this issue Feb 17, 2021 · 1 comment
Closed
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: medium Medium impact/importance bug

Comments

@zephyrbot
Copy link
Collaborator

Static code scan issues found in file:

https://github.com/zephyrproject-rtos/zephyr/tree/fe7c2efca800a0cf1bccf23aefe08b3c4beb88bf/subsys/bluetooth/host/gatt.c#L1303

Category: Memory - corruptions
Function: get_service_handles
Component: Bluetooth
CID: 218728

Details:

1297     static uint8_t get_service_handles(const struct bt_gatt_attr *attr,
1298                        uint16_t handle, void *user_data)
1299     {
1300         struct gatt_incl *include = user_data;
1301    
1302         /* Stop if attribute is a service */
>>>     CID 218728:    (OVERRUN)
>>>     Overrunning array "struct bt_uuid_16 [1]({{.uuid = {BT_UUID_TYPE_16}, .val = 10241}})" of 4 bytes by passing it to a function which accesses it at byte offset 16.
1303         if (!bt_uuid_cmp(attr->uuid, BT_UUID_GATT_PRIMARY) ||
1304             !bt_uuid_cmp(attr->uuid, BT_UUID_GATT_SECONDARY)) {
1305             return BT_GATT_ITER_STOP;
1306         }
1307    
1308         include->end_handle = handle;
1297     static uint8_t get_service_handles(const struct bt_gatt_attr *attr,
1298                        uint16_t handle, void *user_data)
1299     {
1300         struct gatt_incl *include = user_data;
1301    
1302         /* Stop if attribute is a service */
>>>     CID 218728:    (OVERRUN)
>>>     Overrunning array "struct bt_uuid_16 [1]({{.uuid = {BT_UUID_TYPE_16}, .val = 10240}})" of 4 bytes by passing it to a function which accesses it at byte offset 16.
1303         if (!bt_uuid_cmp(attr->uuid, BT_UUID_GATT_PRIMARY) ||
1304             !bt_uuid_cmp(attr->uuid, BT_UUID_GATT_SECONDARY)) {
1305             return BT_GATT_ITER_STOP;
1306         }
1307    
1308         include->end_handle = handle;

Please fix or provide comments in coverity using the link:

https://scan9.coverity.com/reports.htm#v32951/p12996.

Note: This issue was created automatically. Priority was set based on classification
of the file affected and the impact field in coverity. Assignees were set using the CODEOWNERS file.

@zephyrbot zephyrbot added bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: medium Medium impact/importance bug labels Feb 17, 2021
@joerchan
Copy link
Contributor

Passing bt_uuid_16 with type BT_UUID_TYPE_16 will not take case branch BT_UUID_TYPE_128 in uuid_to_uuid128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix priority: medium Medium impact/importance bug
Projects
None yet
Development

No branches or pull requests

4 participants