From ed52e3019db392ce7d283f20e605d9f49a40ef2f Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 11 Jun 2026 14:24:12 -0500 Subject: [PATCH] Change handleSetOwner parameter to const reference and improve long name handling --- src/modules/AdminModule.cpp | 17 +++++++++-------- src/modules/AdminModule.h | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 4f0e7c3ca..7e256291c 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -620,19 +620,20 @@ void AdminModule::handleGetModuleConfigResponse(const meshtastic_MeshPacket &mp, * Setter methods */ -void AdminModule::handleSetOwner(meshtastic_User &o) +void AdminModule::handleSetOwner(const meshtastic_User &o) { int changed = 0; - // Apps built against the older 39-byte limit may send longer names; clamp - // before the changed-compare so re-sending the same long name is a no-op. - clampLongName(o.long_name); - if (*o.long_name) { - changed |= strcmp(owner.long_name, o.long_name); - strncpy(owner.long_name, o.long_name, sizeof(owner.long_name)); + // Apps built against the older 39-byte limit may send longer names; clamp + // before the changed-compare so re-sending the same long name is a no-op. + char longName[sizeof(o.long_name)]; + strncpy(longName, o.long_name, sizeof(longName)); + longName[sizeof(longName) - 1] = '\0'; + clampLongName(longName); + changed |= strcmp(owner.long_name, longName); + strncpy(owner.long_name, longName, sizeof(owner.long_name)); owner.long_name[sizeof(owner.long_name) - 1] = '\0'; - sanitizeUtf8(owner.long_name, sizeof(owner.long_name)); } if (*o.short_name) { changed |= strcmp(owner.short_name, o.short_name); diff --git a/src/modules/AdminModule.h b/src/modules/AdminModule.h index 81796d913..aeb41471c 100644 --- a/src/modules/AdminModule.h +++ b/src/modules/AdminModule.h @@ -58,7 +58,7 @@ class AdminModule : public ProtobufModule, public Obser /** * Setters */ - void handleSetOwner(meshtastic_User &o); + void handleSetOwner(const meshtastic_User &o); void handleSetChannel(const meshtastic_Channel &cc); protected: