Repeater, room server, sensor: fix CLI reply buffer overflow, OTA bounds checks, and ACL slot rotation

This commit is contained in:
tth committed 2026-12-02 00:12:33 +01:00
1 parent 41c7697e6d
commit aa7b181944
5 files changed
+15 -11

No files matched your search

+6 -5
View File
@@ -63,9 +63,10 @@ void ClientACL::load(FILESYSTEM* fs, const mesh::LocalIdentity& self_id) {
#define ACL_TS_RECORD (ACL_TS_PREFIX + 4)
static const char* tsFilename(uint8_t slot) { return slot ? "/s_acl_ts1" : "/s_acl_ts0"; }
static uint8_t s_ts_buf[2 * MAX_CLIENTS * ACL_TS_RECORD + 8];
void ClientACL::loadTimestamps() {
static uint8_t buf[2 * MAX_CLIENTS * ACL_TS_RECORD + 8];
uint8_t* buf = s_ts_buf;
_num_ts_orphans = 0;
_ts_seq = 0;
_ts_slot = 0;
@@ -78,7 +79,7 @@ void ClientACL::loadTimestamps() {
File file = _fs->open(tsFilename(slot));
#endif
if (!file) continue;
int len = file.read(buf, sizeof(buf));
int len = file.read(buf, sizeof(s_ts_buf));
file.close();
if (len < 8 || (len - 8) % ACL_TS_RECORD != 0) continue;
@@ -121,7 +122,7 @@ void ClientACL::loadTimestamps() {
void ClientACL::saveTimestamps() {
if (!_fs) return;
static uint8_t buf[2 * MAX_CLIENTS * ACL_TS_RECORD + 8];
uint8_t* buf = s_ts_buf;
int len = 0;
for (int i = 0; i < num_clients; i++) {
if (clients[i].saved_timestamp == 0) continue;
@@ -142,10 +143,10 @@ void ClientACL::saveTimestamps() {
File file = openWrite(_fs, tsFilename(_ts_slot));
if (file) {
file.write(buf, len);
size_t written = file.write(buf, len);
file.close();
if (written == (size_t)len) _ts_slot ^= 1;
}
_ts_slot ^= 1;
}
void ClientACL::orphanTimestamp(const ClientInfo* c) {