qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH STABLE 2.5] vnc: fix VNC websockets TLS handshake


From: Daniel P. Berrange
Subject: [Qemu-devel] [PATCH STABLE 2.5] vnc: fix VNC websockets TLS handshake
Date: Tue, 7 Jun 2016 15:17:33 +0100

If the VNC websockets TLS handshake blocked, we register a
callback to continue it after the socket signals data is
available. Unfortunately we were mistakenly registering
the wrong method callback, causing us to restart the TLS
handshake from the begining, which obviously fails.

Reported-by: Ben Aitchison <address@hidden>
Signed-off-by: Daniel P. Berrange <address@hidden>
---
 ui/vnc-ws.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

NB this is a stable-2.5 only patch, with no equiv in master
since the code was totally refactored in 2.6

diff --git a/ui/vnc-ws.c b/ui/vnc-ws.c
index 175ea50..a8cf180 100644
--- a/ui/vnc-ws.c
+++ b/ui/vnc-ws.c
@@ -22,8 +22,9 @@
 #include "qemu/main-loop.h"
 #include "crypto/hash.h"
 
-static int vncws_start_tls_handshake(VncState *vs)
+static void vncws_run_tls_handshake(void *opaque)
 {
+    VncState *vs = (VncState *)opaque;
     Error *err = NULL;
 
     if (qcrypto_tls_session_handshake(vs->tls, &err) < 0) {
@@ -42,22 +43,21 @@ static int vncws_start_tls_handshake(VncState *vs)
 
     case QCRYPTO_TLS_HANDSHAKE_RECVING:
         VNC_DEBUG("Handshake interrupted (blocking read)\n");
-        qemu_set_fd_handler(vs->csock, vncws_tls_handshake_io, NULL, vs);
+        qemu_set_fd_handler(vs->csock, vncws_run_tls_handshake, NULL, vs);
         break;
 
     case QCRYPTO_TLS_HANDSHAKE_SENDING:
         VNC_DEBUG("Handshake interrupted (blocking write)\n");
-        qemu_set_fd_handler(vs->csock, NULL, vncws_tls_handshake_io, vs);
+        qemu_set_fd_handler(vs->csock, NULL, vncws_run_tls_handshake, vs);
         break;
     }
 
-    return 0;
+    return;
 
  error:
     VNC_DEBUG("Handshake failed %s\n", error_get_pretty(err));
     error_free(err);
     vnc_client_error(vs);
-    return -1;
 }
 
 void vncws_tls_handshake_io(void *opaque)
@@ -84,7 +84,7 @@ void vncws_tls_handshake_io(void *opaque)
                                       vs);
 
     VNC_DEBUG("Start TLS WS handshake process\n");
-    vncws_start_tls_handshake(vs);
+    vncws_run_tls_handshake(vs);
 }
 
 void vncws_handshake_read(void *opaque)
-- 
2.5.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]