fix(ble/bluedroid): Prevent esp_ble_gatts_send_indicate() with value_len > 512 (IDFGH-13782) #14641
+7
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
BLE indications are limited by max attribute length (512) and also by MTU size - 3 (see https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host/attribute-protocol--att-.html#UUID-fd156898-28db-9cd8-e6e1-94d0278d0d1c).
Checking for MTU size is the user's responsibility, however an easy mistake is to chunk data by MTU size - 3 only. At the maximum MTU size of 517 results in 514, which is greater than 512, and causes heap corruption due to a buffer overflow.
Checklist
Before submitting a Pull Request, please ensure the following: