Skip to content

Commit

Permalink
libvncserver: fix ws subprotocol priority
Browse files Browse the repository at this point in the history
  • Loading branch information
Volodymyr Samokhatko committed Oct 27, 2023
1 parent 9b7b5ff commit 76a0f50
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/libvncserver/websockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ webSocketsHandshake(rfbClientPtr cl, char *scheme)
char *sec_ws_origin = NULL;
char *sec_ws_key = NULL;
char sec_ws_version = 0;
const char *proto_binary;
const char *proto_base64;
ws_ctx_t *wsctx = NULL;

buf = (char *) malloc(WEBSOCKETS_MAX_HANDSHAKE_LEN);
Expand Down Expand Up @@ -289,13 +291,15 @@ webSocketsHandshake(rfbClientPtr cl, char *scheme)
return FALSE;
}

if ((protocol) && (strstr(protocol, "base64"))) {
proto_binary = protocol ? strstr(protocol, "binary") : NULL;
proto_base64 = protocol ? strstr(protocol, "base64") : NULL;
if ((protocol) && (proto_base64 && (!proto_binary || proto_base64 < proto_binary))) {
rfbLog(" - webSocketsHandshake: using base64 encoding\n");
base64 = TRUE;
protocol = "base64";
} else {
rfbLog(" - webSocketsHandshake: using binary/raw encoding\n");
if ((protocol) && (strstr(protocol, "binary"))) {
if ((protocol) && (proto_binary)) {
protocol = "binary";
} else {
protocol = "";
Expand Down

0 comments on commit 76a0f50

Please sign in to comment.