From 02889945cb979a44da00e3336115f2ee24963b47 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Wed, 15 Sep 2010 18:21:42 -0500 Subject: [PATCH] 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. --- utils/websocket.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/utils/websocket.c b/utils/websocket.c index 1402abfd..087085d4 100644 --- a/utils/websocket.c +++ b/utils/websocket.c @@ -350,7 +350,8 @@ ws_ctx_t *do_handshake(int sock) { send(sock, policy_response, sizeof(policy_response), 0); close(sock); return NULL; - } else if (bcmp(handshake, "\x16", 1) == 0) { + } else if ((bcmp(handshake, "\x16", 1) == 0) || + (bcmp(handshake, "\x80", 1) == 0)) { // SSL if (! settings.cert) { return NULL; } 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"); } len = ws_recv(ws_ctx, handshake, 4096); + if (len == 0) { + handler_emsg("Client closed during handshake\n"); + close(sock); + return NULL; + } handshake[len] = 0; if (!parse_handshake(handshake, &headers)) {