[Spice-commits] 3 commits - client/canvas.cpp client/canvas.h client/controller.cpp client/foreign_menu.cpp client/red_gdi_canvas.h client/red_sw_canvas.h

Christophe Fergau teuf at kemper.freedesktop.org
Tue Mar 20 08:54:16 PDT 2012


 client/canvas.cpp       |    1 -
 client/canvas.h         |    3 ---
 client/controller.cpp   |   10 ++++------
 client/foreign_menu.cpp |   13 ++++++++-----
 client/red_gdi_canvas.h |    2 --
 client/red_sw_canvas.h  |    2 --
 6 files changed, 12 insertions(+), 19 deletions(-)

New commits:
commit 64e0974114e4b7e5d737fdf1c19338751064fd0d
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Mar 20 16:07:22 2012 +0100

    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.

diff --git a/client/foreign_menu.cpp b/client/foreign_menu.cpp
index 1010bfb..70b6dc2 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");
     }
commit 3d452a312be3ae1691e9ae310ca15072b04f67c9
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Mar 20 14:51:07 2012 +0100

    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

diff --git a/client/controller.cpp b/client/controller.cpp
index 514bf68..63082c4 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);
commit 01c6f4d2c60ecc360353049f757c60a7fffc81a6
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Mon Mar 5 10:21:29 2012 +0100

    Remove unused Canvas members
    
    The various Canvas have _max and _base variables which are not
    used, better to remove them.

diff --git a/client/canvas.cpp b/client/canvas.cpp
index 0986d47..7d1561a 100644
--- a/client/canvas.cpp
+++ b/client/canvas.cpp
@@ -70,7 +70,6 @@ void Canvas::clear()
 
 void Canvas::begin_draw(SpiceMsgDisplayBase& base, int size, size_t min_size)
 {
-    _base = (uintptr_t)&base;
 }
 
 void Canvas::draw_fill(SpiceMsgDisplayDrawFill& fill, int size)
diff --git a/client/canvas.h b/client/canvas.h
index 5a34bdc..51f2800 100644
--- a/client/canvas.h
+++ b/client/canvas.h
@@ -343,9 +343,6 @@ private:
     ZlibDecoder _zlib_decoder;
 
     SurfacesCache& _surfaces_cache;
-
-    unsigned long _base;
-    unsigned long _max;
 };
 
 
diff --git a/client/red_gdi_canvas.h b/client/red_gdi_canvas.h
index fa173c4..77adcf7 100644
--- a/client/red_gdi_canvas.h
+++ b/client/red_gdi_canvas.h
@@ -48,8 +48,6 @@ private:
     RedPixmapGdi *_helper_pixmap;
     HDC _dc;
     HBITMAP _prev_bitmap;
-    unsigned long _base;
-    unsigned long _max;
 };
 
 #endif
diff --git a/client/red_sw_canvas.h b/client/red_sw_canvas.h
index 4736649..eb577ac 100644
--- a/client/red_sw_canvas.h
+++ b/client/red_sw_canvas.h
@@ -45,8 +45,6 @@ public:
 
 private:
     RedPixmap *_pixmap;
-    unsigned long _base;
-    unsigned long _max;
 };
 
 #endif


More information about the Spice-commits mailing list