Fix BLE name fallback to T1000-E-BOOT for long node names#1801
Open
andrewdefilippis wants to merge 2 commits intomeshcore-dev:devfrom
Open
Fix BLE name fallback to T1000-E-BOOT for long node names#1801andrewdefilippis wants to merge 2 commits intomeshcore-dev:devfrom
andrewdefilippis wants to merge 2 commits intomeshcore-dev:devfrom
Conversation
The Nordic SoftDevice S140 defaults to a 31-byte maximum GAP device
name. When "MeshCore-" (9 bytes) + node_name exceeds 31 bytes (i.e.
node names >= 23 chars), sd_ble_gap_device_name_set() silently fails
and the name falls back to USB_PRODUCT ("T1000-E-BOOT").
Add UTF-8 safe middle-truncation that preserves the beginning and end
of the node name (where users place emoji and device-type identifiers),
fitting the result within the 29-byte scan response limit so it
advertises as COMPLETE_LOCAL_NAME.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
robekl
reviewed
Feb 26, 2026
robekl
reviewed
Feb 26, 2026
The original implementation accepted dest_size but only used it in the snprintf fast path — manual memcpy assembly could overwrite the buffer if a future caller passed a smaller destination. Additionally, an unsigned underflow on name_budget when prefix_len >= BLE_NAME_MAX_LEN could cascade into massive write lengths. - Clamp all output to min(dest_size-1, BLE_NAME_MAX_LEN) via max_out - Guard against prefix_len >= max_out to prevent unsigned underflow - Validate UTF-8 continuation bytes in utf8CharLen to handle malformed node names (truncated sequences, missing continuations) - Fix backward tail walk to detect malformed sequence at name[0] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Any reason not to merge this simple PR? |
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.

Fixes #1769; concatenates head and tail of name to fix BLE name length constraint.