diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2012-03-20 16:07:22 +0100 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2012-03-20 16:53:50 +0100 |
commit | 64e0974114e4b7e5d737fdf1c19338751064fd0d (patch) | |
tree | cd1d0ce16c57815f35b35aabaf5b0ad0c3070601 /client | |
parent | 3d452a312be3ae1691e9ae310ca15072b04f67c9 (diff) | |
download | spice-64e0974114e4b7e5d737fdf1c19338751064fd0d.tar.gz spice-64e0974114e4b7e5d737fdf1c19338751064fd0d.tar.xz spice-64e0974114e4b7e5d737fdf1c19338751064fd0d.zip |
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.
Diffstat (limited to 'client')
-rw-r--r-- | client/foreign_menu.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/client/foreign_menu.cpp b/client/foreign_menu.cpp index 1010bfba..70b6dc23 100644 --- a/client/foreign_menu.cpp +++ b/client/foreign_menu.cpp @@ -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"); } |