fix: bound advert-name copy (corrupt contacts) + log NVS headroom at boot

- MyMesh.cpp: strcpy(p->name, contact.name) could overrun the 32-byte advert_paths
  name field when an over-the-air advert carries a 32-char (unterminated) name,
  corrupting the recently-heard/Found table. Bounded with strncpy + NUL-terminate.
- main.cpp: log nvs_free_entries at boot so a filling NVS (the boot-loop trigger
  under Launcher) is visible in serial before it goes catastrophic.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kaj SchittecatandClaude Opus 4.8 committed 2026-06-13 21:45:08 +02:00
1 parent 58bae913e1
commit 9e2eed1551
2 files changed
+9 -3

No files matched your search

+4 -2
View File
@@ -226,11 +226,13 @@ void setup() {
uint32_t bn = prefs.getUInt("n", 0);
++bn;
prefs.putUInt("n", bn);
size_t nvs_free = prefs.freeEntries(); // NVS partition headroom; near 0 = full (the boot-loop trigger)
prefs.end();
meshcomod_touch_set_boot_stats(bn, static_cast<uint8_t>(esp_reset_reason()));
Serial.printf("[BOOT] touch_boot_n=%lu reason=%u\n",
Serial.printf("[BOOT] touch_boot_n=%lu reason=%u nvs_free_entries=%u\n",
static_cast<unsigned long>(bn),
static_cast<unsigned>(esp_reset_reason()));
static_cast<unsigned>(esp_reset_reason()),
static_cast<unsigned>(nvs_free));
}
the_mesh.initTxtTxUniquenessFromRng();
}