diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2012-03-20 14:51:07 +0100 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2012-03-20 16:53:40 +0100 |
commit | 3d452a312be3ae1691e9ae310ca15072b04f67c9 (patch) | |
tree | 8b8526efe12321cfdc28dcab6129ad916466dfa8 /client | |
parent | 01c6f4d2c60ecc360353049f757c60a7fffc81a6 (diff) |
Don't limit spice controller socket name to 50 chars
The spice controller socket name used to be hardcoded to
/tmp/SpiceController-%lu.uds and generated using snprintf. A 50 bytes
buffer was enough for that, but this was changed in commit 79fffbf95
because this was predictable and allowed other users on the system
to sniff the browser/client communication. spicec now uses the value
of the environment SPICE_XPI_SOCKET as the name of the socket to use.
However, since the name that is used is no longer generated by spicec,
no assumption can be made about its size. Currently, the socket is
created inside the user home directory, which means that if the
user name is too long, spicec will not be able to read the controller
socket name.
This commit directly uses the string from getenv as he name of the
controller socket (on Linux) instead of limiting its size to 50 characters,
which should fix this issue.
This fixes rhbz #804561
Diffstat (limited to 'client')
-rw-r--r-- | client/controller.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/client/controller.cpp b/client/controller.cpp index 514bf68a..63082c49 100644 --- a/client/controller.cpp +++ b/client/controller.cpp @@ -27,9 +27,9 @@ #include "debug.h" #include "platform.h" -#define PIPE_NAME_MAX_LEN 50 #ifdef WIN32 +#define PIPE_NAME_MAX_LEN 50 #define PIPE_NAME "SpiceController-%lu" #endif @@ -38,18 +38,16 @@ Controller::Controller(ControllerInterface *handler) , _exclusive (false) , _refs (1) { - char pipe_name[PIPE_NAME_MAX_LEN]; - ASSERT(_handler); #ifdef WIN32 + char pipe_name[PIPE_NAME_MAX_LEN]; snprintf(pipe_name, PIPE_NAME_MAX_LEN, PIPE_NAME, Platform::get_process_id()); #else - const char *p_socket = getenv("SPICE_XPI_SOCKET"); - if (!p_socket) { + const char *pipe_name = getenv("SPICE_XPI_SOCKET"); + if (!pipe_name) { LOG_ERROR("Failed to get a controller connection (SPICE_XPI_SOCKET)"); throw Exception("Failed to get a controller connection (SPICE_XPI_SOCKET)"); } - strncpy(pipe_name, p_socket, sizeof(pipe_name)); #endif LOG_INFO("Creating a controller connection %s", pipe_name); _pipe = NamedPipe::create(pipe_name, *this); |