mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-26 22:48:19 +00:00
Don't truncate SPICE_FOREIGN_MENU_SOCKET
When we get the socket name for the foreign menu socket from an environment variable, we cannot make assumptions about its length. Currently, we are strncpying to a 50 byte buffer which is easily too small.
This commit is contained in:
parent
3d452a312b
commit
64e0974114
@ -46,13 +46,16 @@ ForeignMenu::ForeignMenu(ForeignMenuInterface *handler, bool active)
|
||||
ASSERT(_handler != NULL);
|
||||
#ifndef WIN32
|
||||
const char *p_socket = getenv("SPICE_FOREIGN_MENU_SOCKET");
|
||||
if (p_socket)
|
||||
strncpy(pipe_name, p_socket, sizeof(pipe_name));
|
||||
else
|
||||
if (p_socket) {
|
||||
LOG_INFO("Creating a foreign menu connection %s", p_socket);
|
||||
_foreign_menu = NamedPipe::create(p_socket, *this);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
snprintf(pipe_name, PIPE_NAME_MAX_LEN, PIPE_NAME, Platform::get_process_id());
|
||||
LOG_INFO("Creating a foreign menu connection %s", pipe_name);
|
||||
_foreign_menu = NamedPipe::create(pipe_name, *this);
|
||||
LOG_INFO("Creating a foreign menu connection %s", pipe_name);
|
||||
_foreign_menu = NamedPipe::create(pipe_name, *this);
|
||||
}
|
||||
if (!_foreign_menu) {
|
||||
LOG_ERROR("Failed to create a foreign menu connection");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user