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

Fix string buffer length in UUID trace helper #14574

Merged
merged 1 commit into from
May 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion connectivity/FEATURE_BLE/source/common/ble_trace_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,12 @@ const char *to_string(const UUID& uuid)
static constexpr const char *HEX = "0123456789ABCDEF";
static constexpr const size_t HYPHENS_DELIMITER_COUNT = 4;

static char string_buffer[ROW_COUNT][UUID::LENGTH_OF_LONG_UUID + HYPHENS_DELIMITER_COUNT];
/*
* For each hex digit, we require 2 bytes. So, we need at most 2 * 16 = 32 bytes for the hex digits.
* In the case of 128-bit UUIDs, we also need space for 4 hyphen delimiters.
* An additional byte is required at the end of each array to store the null terminator.
*/
static char string_buffer[ROW_COUNT][2 * UUID::LENGTH_OF_LONG_UUID + HYPHENS_DELIMITER_COUNT + 1];
static uint8_t idx = 0;

++idx;
Expand Down