Safer and more efficient handling of the internal whitelist#1087
Open
doudar wants to merge 15 commits intoh2zero:masterfrom
Open
Safer and more efficient handling of the internal whitelist#1087doudar wants to merge 15 commits intoh2zero:masterfrom
doudar wants to merge 15 commits intoh2zero:masterfrom
Conversation
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Compact whitelist handling in NimBLEDevice
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Refactor `NimBLECharacteristic` control flow for smaller hot-path overhead
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Refactor NimBLEClient service lookup path to reduce duplicate work and branch repetition
h2zero
reviewed
Feb 14, 2026
| return create2904(); | ||
| } | ||
|
|
||
| NimBLEDescriptor* pDescriptor = new NimBLEDescriptor(uuid, properties, maxLen, this); |
| } else { | ||
| m_pCallbacks = &defaultCallback; | ||
| } | ||
| m_pCallbacks = pCallbacks != nullptr ? pCallbacks : &defaultCallback; |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request makes several improvements and bug fixes to the whitelist management logic in
NimBLEDevice. The changes focus on safer and more efficient handling of the internal whitelist vector, as well as correcting a boundary check bug.Whitelist management improvements:
m_whiteListfrom pointer arithmetic (&m_whiteList[0]) to the safer and more idiomaticm_whiteList.data()when passing data toble_gap_wl_set.whiteListRemove, now passesnullptrtoble_gap_wl_setwhen the whitelist is empty, preventing invalid pointer dereference. Also usesm_whiteList.shrink_to_fit()to optimize memory usage after removal, replacing the previous swap idiom.Bug fix:
getWhiteListAddressfromindex > m_whiteList.size()toindex >= m_whiteList.size(), fixing an off-by-one error when accessing whitelist entries.NimBLECharacteristic changes:
Validation performed
Security Summary
NimBLEClient changes:
const std::string uuidStr = uuid.toString();
NIMBLE_LOGD(LOG_TAG, ">> getService: uuid: %s", uuidStr.c_str());
size_t prevSize = m_svcVec.size();
auto getLastIfAdded = this, prevSize -> NimBLERemoteService* {
return m_svcVec.size() > prevSize ? m_svcVec.back() : nullptr;
};