[Spice-commits] server/reds.cpp

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jul 25 08:11:33 UTC 2022


 server/reds.cpp |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 36f501ef7567c390b9c25cc6c3e59ab37e051942
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Mon Jul 18 16:46:44 2022 +0400

    Generate a random connection ID with g_random_int()
    
    Spice uses rand() to generate the random id, but qemu (at least in the case
    of qemu-system-x86) fails to initialize the RNG seed (with e.g. srand()).
    
    The result is, that every SPICE session started (by e.g. libvirtd) has the
    same client_id. Usually, this is not a problem, but running something like
    a SPICE proxy, relying on the client_id to correctly route connections,
    this creates problems.
    
    Fixes:
    https://gitlab.com/qemu-project/qemu/-/issues/163
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>

diff --git a/server/reds.cpp b/server/reds.cpp
index 06702371..49113316 100644
--- a/server/reds.cpp
+++ b/server/reds.cpp
@@ -1781,7 +1781,7 @@ static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link)
 
     if (link_mess->connection_id == 0) {
         reds_send_link_result(link, SPICE_LINK_ERR_OK);
-        while((connection_id = rand()) == 0);
+        while((connection_id = g_random_int()) == 0);
         mig_target = FALSE;
     } else {
         // TODO: make sure link_mess->connection_id is the same


More information about the Spice-commits mailing list