Преглед изворни кода

C proxy: Issue #14: wss:// from Safari

Addresses this issue:
http://github.com/kanaka/noVNC/issues#issue/14

This goes along with commit 7e63919e6 but for the C proxy.
Joel Martin пре 15 година
родитељ
комит
02889945cb
1 измењених фајлова са 7 додато и 1 уклоњено
  1. 7 1
      utils/websocket.c

+ 7 - 1
utils/websocket.c

@@ -350,7 +350,8 @@ ws_ctx_t *do_handshake(int sock) {
         send(sock, policy_response, sizeof(policy_response), 0);
         send(sock, policy_response, sizeof(policy_response), 0);
         close(sock);
         close(sock);
         return NULL;
         return NULL;
-    } else if (bcmp(handshake, "\x16", 1) == 0) {
+    } else if ((bcmp(handshake, "\x16", 1) == 0) ||
+               (bcmp(handshake, "\x80", 1) == 0)) {
         // SSL
         // SSL
         if (! settings.cert) { return NULL; }
         if (! settings.cert) { return NULL; }
         ws_ctx = ws_socket_ssl(sock, settings.cert);
         ws_ctx = ws_socket_ssl(sock, settings.cert);
@@ -368,6 +369,11 @@ ws_ctx_t *do_handshake(int sock) {
         handler_msg("using plain (not SSL) socket\n");
         handler_msg("using plain (not SSL) socket\n");
     }
     }
     len = ws_recv(ws_ctx, handshake, 4096);
     len = ws_recv(ws_ctx, handshake, 4096);
+    if (len == 0) {
+        handler_emsg("Client closed during handshake\n");
+        close(sock);
+        return NULL;
+    }
     handshake[len] = 0;
     handshake[len] = 0;
 
 
     if (!parse_handshake(handshake, &headers)) {
     if (!parse_handshake(handshake, &headers)) {