mirror of
https://github.com/wolfpld/tracy.git
synced 2026-11-19 22:25:59 +00:00
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:
co-authored by
Claude Opus 5.5
parent
f2a4f2529e
commit
6fddfdbe22
@@ -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]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user