mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-02 18:26:11 +00:00
fix: smaller audit items — strnlen, narrow-display guard, SNR precision
M2: CMD_SET_DEFAULT_FLOOD_SCOPE used strlen() on the frame's 31-byte name slot, which is not required to be NUL-terminated. Switched to strnlen() so the search can't run past the field into the 16-byte key. M4: NearbyScreen::renderDiscoverDetail computed strncpy(b64, ..., max_chars - 3) where max_chars came from display width. On very narrow displays (width < ~28 at 6 px font) this became negative. Skip the pub-key line entirely when max_chars < 4 so we don't risk a negative count and a bogus terminator. L1: SNR was shown as truncated integer dB. Switched the detail view and the 2-line discover cards to %.1f so they keep the 0.25 dB resolution (consistent with the ping popup, which already used %.1f). L4: Two fallback "?" sender placeholders used strncpy(buf, "?", sizeof(buf)) — functional but it memsets 21 unused bytes for a one-character string. Replaced with strcpy. M1 marked as not-a-bug after re-check: default_scope_name is char[31], so the n < 31 guard correctly admits the max 30-char string + NUL. FEATURES.md audit section updated with current status. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -784,7 +784,7 @@ public:
|
||||
strncpy(fsender, ftext, nl); fsender[nl] = '\0';
|
||||
strncpy(fmsg, fsep + 2, sizeof(fmsg) - 1); fmsg[sizeof(fmsg)-1] = '\0';
|
||||
} else {
|
||||
strncpy(fsender, "?", sizeof(fsender));
|
||||
strcpy(fsender, "?");
|
||||
strncpy(fmsg, ftext, sizeof(fmsg) - 1); fmsg[sizeof(fmsg)-1] = '\0';
|
||||
}
|
||||
int ret = _fs.render(display, fsender, fmsg,
|
||||
@@ -857,7 +857,7 @@ public:
|
||||
strncpy(msg_part, sep + 2, sizeof(msg_part) - 1);
|
||||
msg_part[sizeof(msg_part) - 1] = '\0';
|
||||
} else {
|
||||
strncpy(sender, "?", sizeof(sender));
|
||||
strcpy(sender, "?");
|
||||
strncpy(msg_part, text, sizeof(msg_part) - 1);
|
||||
msg_part[sizeof(msg_part) - 1] = '\0';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user