-
-
Notifications
You must be signed in to change notification settings - Fork 204
Safer and more efficient handling of the internal whitelist #1087
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
Open
doudar
wants to merge
15
commits into
h2zero:master
Choose a base branch
from
doudar:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+24
−28
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e0a6321
Initial plan
Copilot 3322b6e
Tighten whitelist handling and bounds checks
Copilot fc0778f
Always shrink whitelist after removal
Copilot b5bde90
Clarify whitelist removal flow
Copilot 1eb35e8
Update status
Copilot e138ad1
Remove CodeQL artifact
Copilot 42bc377
Merge pull request #5 from doudar/copilot/refactor-nimbledevice-code
doudar 00c3ec4
Initial plan
Copilot 91622d6
Refactor NimBLECharacteristic hot paths minimally
Copilot 68343c9
Address code review naming feedback
Copilot 78a42af
Merge pull request #6 from doudar/copilot/refactor-nimble-characteristic
doudar 1e8ee78
Initial plan
Copilot c28168d
refactor: reduce duplicate work in NimBLEClient::getService
Copilot 3c81e21
chore: clarify helper naming in NimBLEClient getService
Copilot 2fe5031
Merge pull request #7 from doudar/copilot/refactor-nimbleclient-code
doudar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| docs/doxydocs | ||
| .development | ||
| _codeql_detected_source_root |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,14 +82,12 @@ NimBLEDescriptor* NimBLECharacteristic::createDescriptor(const char* uuid, uint3 | |
| * @return The new BLE descriptor. | ||
| */ | ||
| NimBLEDescriptor* NimBLECharacteristic::createDescriptor(const NimBLEUUID& uuid, uint32_t properties, uint16_t maxLen) { | ||
| NimBLEDescriptor* pDescriptor = nullptr; | ||
| if (uuid == NimBLEUUID(static_cast<uint16_t>(0x2904))) { | ||
| NIMBLE_LOGW(LOG_TAG, "0x2904 descriptor should be created with create2904()"); | ||
| pDescriptor = create2904(); | ||
| } else { | ||
| pDescriptor = new NimBLEDescriptor(uuid, properties, maxLen, this); | ||
| return create2904(); | ||
| } | ||
|
|
||
| NimBLEDescriptor* pDescriptor = new NimBLEDescriptor(uuid, properties, maxLen, this); | ||
| addDescriptor(pDescriptor); | ||
| return pDescriptor; | ||
| } // createDescriptor | ||
|
|
@@ -277,9 +275,10 @@ bool NimBLECharacteristic::sendValue(const uint8_t* value, size_t length, bool i | |
| const auto subs = getSubscribers(); // make a copy to avoid issues if subscribers change while sending | ||
| ble_npl_hw_exit_critical(0); | ||
|
|
||
| bool chSpecified = connHandle != BLE_HS_CONN_HANDLE_NONE; | ||
| bool requireSecure = m_properties & (BLE_GATT_CHR_F_READ_ENC | BLE_GATT_CHR_F_READ_AUTHEN | BLE_GATT_CHR_F_READ_AUTHOR); | ||
| const bool chSpecified = connHandle != BLE_HS_CONN_HANDLE_NONE; | ||
| const bool requireSecure = m_properties & (BLE_GATT_CHR_F_READ_ENC | BLE_GATT_CHR_F_READ_AUTHEN | BLE_GATT_CHR_F_READ_AUTHOR); | ||
| int rc = chSpecified ? BLE_HS_ENOENT : 0; // if handle specified, assume not found until sent | ||
| auto sendFunc = isNotification ? ble_gatts_notify_custom : ble_gatts_indicate_custom; | ||
|
|
||
| // Notify all connected peers unless a specific handle is provided | ||
| for (const auto& entry : subs) { | ||
|
|
@@ -306,11 +305,7 @@ bool NimBLECharacteristic::sendValue(const uint8_t* value, size_t length, bool i | |
| break; | ||
| } | ||
|
|
||
| if (isNotification) { | ||
| rc = ble_gatts_notify_custom(ch, m_handle, om); | ||
| } else { | ||
| rc = ble_gatts_indicate_custom(ch, m_handle, om); | ||
| } | ||
| rc = sendFunc(ch, m_handle, om); | ||
|
|
||
| if (rc != 0 || chSpecified) { | ||
| break; | ||
|
|
@@ -437,11 +432,7 @@ void NimBLECharacteristic::writeEvent(const uint8_t* val, uint16_t len, NimBLECo | |
| * used to define any callbacks for the characteristic. | ||
| */ | ||
| void NimBLECharacteristic::setCallbacks(NimBLECharacteristicCallbacks* pCallbacks) { | ||
| if (pCallbacks != nullptr) { | ||
| m_pCallbacks = pCallbacks; | ||
| } else { | ||
| m_pCallbacks = &defaultCallback; | ||
| } | ||
| m_pCallbacks = pCallbacks != nullptr ? pCallbacks : &defaultCallback; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol |
||
| } // setCallbacks | ||
|
|
||
| /** | ||
|
|
||
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this one