Client: don't overflow the broadcast program name

GetBroadcastMessage is given strlen(m_programName), which can exceed
WelcomeMessageProgramNameSize when the program name is set with a long
string (e.g. by the Python bindings). Clamp the length inside
GetBroadcastMessage, which owns the fixed-size buffer.

Also null-terminate names stored in the Python NameBuffer and reject
names that leave no room for the terminator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Clément Grégoire
2026-11-09 18:19:40 +01:00
co-authored by Claude Opus 5.5
parent f2a4f2529e
commit 6fddfdbe22
2 changed files with 3 additions and 1 deletions
+2 -1
View File
@@ -43,11 +43,12 @@ class NameBuffer {
BufferEntry add(const std::string& name) {
std::lock_guard<std::mutex> lock(m_mutex);
if (m_index >= BUFFER_SIZE || name.size() > NAME_LENGTH)
if (m_index >= BUFFER_SIZE || name.size() >= NAME_LENGTH)
return std::make_pair(std::nullopt, nullptr);
auto index = m_index++;
name.copy(m_buffer[index], name.size());
m_buffer[index][name.size()] = '\0';
return std::make_pair(index, m_buffer[index]);
}