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:
1 parent
505ae195dd
commit
e86ed1373b
3 files changed
+7
-6
No files matched your search
@@ -739,9 +739,9 @@ public:
|
||||
auto p = &unread[head];
|
||||
p->timestamp = _rtc->getCurrentTime();
|
||||
if (path_count == 0xFF) {
|
||||
sprintf(p->origin, "(D) %s:", from_name);
|
||||
snprintf(p->origin, sizeof(p->origin), "(D) %s:", from_name);
|
||||
} else {
|
||||
sprintf(p->origin, "(%d) %s:", (uint32_t) path_count, from_name);
|
||||
snprintf(p->origin, sizeof(p->origin), "(%d) %s:", (uint32_t) path_count, from_name);
|
||||
}
|
||||
StrHelper::strncpy(p->msg, msg, sizeof(p->msg));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user