Skip to content

Commit fe6607c

Browse files
author
Volodymyr Samokhatko
committed
libvncserver: fix ws subprotocol priority
1 parent 9b7b5ff commit fe6607c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/libvncserver/websockets.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ webSocketsHandshake(rfbClientPtr cl, char *scheme)
168168
char *sec_ws_origin = NULL;
169169
char *sec_ws_key = NULL;
170170
char sec_ws_version = 0;
171+
const char *proto_binary;
172+
const char *proto_base64;
171173
ws_ctx_t *wsctx = NULL;
172174

173175
buf = (char *) malloc(WEBSOCKETS_MAX_HANDSHAKE_LEN);
@@ -289,13 +291,15 @@ webSocketsHandshake(rfbClientPtr cl, char *scheme)
289291
return FALSE;
290292
}
291293

292-
if ((protocol) && (strstr(protocol, "base64"))) {
294+
proto_binary = strstr(protocol, "binary");
295+
proto_base64 = strstr(protocol, "base64");
296+
if ((protocol) && (proto_base64 && (!proto_binary || proto_base64 < proto_binary))) {
293297
rfbLog(" - webSocketsHandshake: using base64 encoding\n");
294298
base64 = TRUE;
295299
protocol = "base64";
296300
} else {
297301
rfbLog(" - webSocketsHandshake: using binary/raw encoding\n");
298-
if ((protocol) && (strstr(protocol, "binary"))) {
302+
if ((protocol) && (proto_binary)) {
299303
protocol = "binary";
300304
} else {
301305
protocol = "";

0 commit comments

Comments
 (0)