From 2a277ff8e96815cdfa63046fcb2aa02154319c00 Mon Sep 17 00:00:00 2001 From: mch <32224+hamsolodev@users.noreply.github.com> Date: Sun, 22 Nov 2026 14:22:03 +1100 Subject: [PATCH] companion: clear the old default scope name when a shorter one is set CMD_SET_DEFAULT_FLOOD_SCOPE copied the new name over the old one with strcpy, leaving the bytes after its NUL as they were. A shorter name set over a longer one kept the longer one's tail, and CMD_GET_DEFAULT_FLOOD_SCOPE sends all 31 bytes of the field. Copy with StrHelper::strzcpy, which NUL-pads the rest of the field. Fixes #3891 --- examples/companion_radio/MyMesh.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index 9dcb9d050f..a594d4ec51 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -1980,7 +1980,7 @@ void MyMesh::handleCmdFrame(size_t len) { if (len >= 1+31+16) { int n = strlen((char *) &cmd_frame[1]); if (n > 0 && n < 31) { - strcpy(_prefs.default_scope_name, (char *) &cmd_frame[1]); + StrHelper::strzcpy(_prefs.default_scope_name, (char *) &cmd_frame[1], sizeof(_prefs.default_scope_name)); memcpy(_prefs.default_scope_key, &cmd_frame[1+31], 16); savePrefs(); writeOKFrame();