You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
btc_ble_gattc_get_attr_count takes a uint16_t* for count. It, in turn, calls BTA_GATTC_GetDBSizeByType and casts as an int*. As an int is 32 bits and uint16 is 16, the result overwrites part of the stack by 16 bytes.
A call to btc_ble_gattc_get_attr_count should not affect local variables.
Actual Behavior
When I called btc_ble_gattc_get_attr_count, it would overwrite a local variable on the stack. Similar to the gattc_multi_connect example, I would set notify_en=1. In some cases the value would be reset to 0 when btc_ble_gattc_get_attr_count is called.
Steps to reproduce
Debug gattc_multi_connect into BTA_GATTC_GetDBSizeByType and see how the stack is overwritten.
Code to reproduce this issue
You can use gattc_multi_connect and debug into btc_ble_gattc_get_attr_count in the case ESP_GATTC_REG_FOR_NOTIFY_EVT.
The text was updated successfully, but these errors were encountered:
github-actionsbot
changed the title
Stack corruption calling btc_ble_gattc_get_attr_count uint16_t* assumed to be int*
Stack corruption calling btc_ble_gattc_get_attr_count uint16_t* assumed to be int* (IDFGH-2560)
Jan 17, 2020
#4100
''' Environment
Problem Description
btc_ble_gattc_get_attr_count takes a uint16_t* for count. It, in turn, calls BTA_GATTC_GetDBSizeByType and casts as an int*. As an int is 32 bits and uint16 is 16, the result overwrites part of the stack by 16 bytes.
This code change in fixes the issue for me
Expected Behavior
A call to btc_ble_gattc_get_attr_count should not affect local variables.
Actual Behavior
When I called btc_ble_gattc_get_attr_count, it would overwrite a local variable on the stack. Similar to the gattc_multi_connect example, I would set notify_en=1. In some cases the value would be reset to 0 when btc_ble_gattc_get_attr_count is called.
Steps to reproduce
Debug gattc_multi_connect into BTA_GATTC_GetDBSizeByType and see how the stack is overwritten.
Code to reproduce this issue
You can use gattc_multi_connect and debug into btc_ble_gattc_get_attr_count in the case ESP_GATTC_REG_FOR_NOTIFY_EVT.
The text was updated successfully, but these errors were encountered: