diff --git a/src/MyMesh.cpp b/src/MyMesh.cpp index 416c7f3f..925de324 100644 --- a/src/MyMesh.cpp +++ b/src/MyMesh.cpp @@ -1724,7 +1724,11 @@ void MyMesh::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path } memcpy(p->pubkey_prefix, contact.id.pub_key, sizeof(p->pubkey_prefix)); - strcpy(p->name, contact.name); + // contact.name is from an over-the-air advert and may fill its 32-byte field + // with no NUL terminator; an unbounded strcpy would then run past p->name and + // corrupt the advert_paths table (garbled "Found"/recently-heard entries). + strncpy(p->name, contact.name, sizeof(p->name) - 1); + p->name[sizeof(p->name) - 1] = '\0'; p->recv_timestamp = getRTCClock()->getCurrentTime(); p->path_len = path_len; memcpy(p->path, path, p->path_len); diff --git a/src/main.cpp b/src/main.cpp index 0c28c8ff..79fa8530 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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(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(bn), - static_cast(esp_reset_reason())); + static_cast(esp_reset_reason()), + static_cast(nvs_free)); } the_mesh.initTxtTxUniquenessFromRng(); }