Terminate contact names received from the app

updateContactFromFrame() copies 32 name bytes from the companion frame
without terminating them, so an app (or a corrupt frame) can store a name
with no NUL. The UI then passes it to sprintf() into fixed-size origin
buffers. Terminate the name on receipt and use snprintf() in both UIs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mark RoseandClaude Opus 5.5 committed 2026-11-26 00:02:20 -06:00
1 parent 505ae195dd
commit e86ed1373b
3 files changed
+7 -6

No files matched your search

+1
View File
@@ -202,6 +202,7 @@ void MyMesh::updateContactFromFrame(ContactInfo &contact, uint32_t& last_mod, co
memcpy(contact.out_path, &frame[i], MAX_PATH_SIZE);
i += MAX_PATH_SIZE;
memcpy(contact.name, &frame[i], 32);
contact.name[sizeof(contact.name) - 1] = 0; // the app is not trusted to NUL-terminate
i += 32;
memcpy(&contact.last_advert_timestamp, &frame[i], 4);
i += 4;