tests: cover CLI prefix stripping, set-pin gate, paged reply bounds, and ACL write failures

Changelog: -
This commit is contained in:
tth committed 2026-12-02 00:36:05 +01:00
1 parent 0dcc9c6e06
commit 5f31fc8e50
6 files changed
+192 -35

No files matched your search

+8 -18
View File
@@ -2126,14 +2126,7 @@ void MyMesh::enterCLIRescue() {
extern "C" void retainedClockInvalidate() __attribute__((weak)); // NRF52Board.cpp
bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char* reply) {
while (*command == ' ') command++; // skip leading spaces
if (strlen(command) > 4 && command[2] == '|') { // optional prefix (for companion radio CLI)
memcpy(reply, command, 3); // reflect the prefix back
reply += 3;
*reply = 0;
command += 3;
}
cli_args::stripPrefix(command, reply);
if (_prefs.getRadioPrefs()->handleCommand(command, sender_timestamp, reply)) { // is radio CLI command?
if (_prefs.getRadioPrefs()->isDirty()) { savePrefs(); }
@@ -2207,18 +2200,15 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char*
#endif
if (memcmp(command, "set pin ", 8) == 0) {
const char* err = nullptr;
#ifdef LOCKED_NODE
if (_cli_rescue) {
// CUSTOM (TeTeHacko): a known PIN = pair and read it all (checked after
// leading-space and XX| stripping so " set pin ..." cannot bypass it)
strcpy(reply, "Error: locked build");
return true;
}
const bool locked = true;
#else
const bool locked = false;
#endif
if (sender_timestamp == 0 && !_cli_rescue && (!_serial || !_serial->isConnectionSecure())) {
// CUSTOM (TeTeHacko): the same gate as CMD_SET_DEVICE_PIN -- through the
// CLI, USB set the PIN it may not set directly, then paired over BLE
strcpy(reply, "Error: set pin only over paired BLE");
if (!cli_args::canSetPin(sender_timestamp, _cli_rescue, locked,
_serial && _serial->isConnectionSecure(), &err)) {
strcpy(reply, err);
return true;
}
long pin; // atoi(): "abc" was PIN 0, i.e. a random one