tests: cover CLI prefix stripping, set-pin gate, paged reply bounds, and ACL write failures
Changelog: -
This commit is contained in:
1 parent
0dcc9c6e06
commit
5f31fc8e50
6 files changed
+192
-35
No files matched your search
@@ -1,5 +1,6 @@
|
||||
#include "MyMesh.h"
|
||||
#include <algorithm>
|
||||
#include <helpers/CliArgs.h>
|
||||
#include <helpers/sensors/LPPDataHelpers.h>
|
||||
#include <helpers/UTF8Helpers.h>
|
||||
|
||||
@@ -219,9 +220,7 @@ void MyMesh::formatNodesReply(char* reply, int max_len, uint16_t offset) {
|
||||
prefix, (unsigned)n->type, (long)n->lat, (long)n->lon,
|
||||
(int)n->snr, (int)n->rssi, (unsigned long)(now - n->heard_timestamp),
|
||||
(unsigned long)n->pkt_hash, pathhex, n->name);
|
||||
int ll = strlen(line);
|
||||
if ((dp - reply) + ll + 24 > max_len) break; // room for trailer; never overflow reply
|
||||
memcpy(dp, line, ll); dp += ll;
|
||||
if (!cli_args::appendLine(dp, reply, max_len, 24, line)) break; // room for trailer; never overflow reply
|
||||
}
|
||||
dp += sprintf(dp, "E,%d,%d", i, total);
|
||||
*dp = 0;
|
||||
@@ -276,9 +275,7 @@ void MyMesh::formatRxLogReply(char* reply, int max_len, uint32_t cursor) {
|
||||
(unsigned long)r->seq, (unsigned long)r->when,
|
||||
(unsigned long)r->pkt_hash, (unsigned)r->header,
|
||||
(int)r->snr, (int)r->rssi, pathhex);
|
||||
int ll = strlen(line);
|
||||
if ((dp - reply) + ll + 40 > max_len) break; // room for trailer; never overflow reply
|
||||
memcpy(dp, line, ll); dp += ll;
|
||||
if (!cli_args::appendLine(dp, reply, max_len, 40, line)) break; // room for trailer; never overflow reply
|
||||
last = r->seq;
|
||||
}
|
||||
dp += sprintf(dp, "E,%lu,%lu,%lu", (unsigned long)last, (unsigned long)oldest, (unsigned long)newest);
|
||||
@@ -1931,12 +1928,9 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply
|
||||
}
|
||||
#endif
|
||||
|
||||
if (strlen(command) > 4 && command[2] == '|') { // optional prefix (for companion radio CLI)
|
||||
memcpy(reply, command, 3); // reflect the prefix back
|
||||
reply += 3;
|
||||
reply_max = reply_max > 3 ? reply_max - 3 : 0;
|
||||
command += 3;
|
||||
}
|
||||
const char* cmd = command;
|
||||
cli_args::stripPrefix(cmd, reply, &reply_max);
|
||||
command = const_cast<char*>(cmd);
|
||||
|
||||
// handle ACL related commands
|
||||
if (memcmp(command, "setperm ", 8) == 0) { // format: setperm {pubkey-hex} {permissions-int8}
|
||||
|
||||
Reference in new issue
Block a user