From b54bc178f0fa01a11794db1adac5072f7fb47b41 Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Tue, 8 Oct 2019 18:12:57 +0000 Subject: [PATCH] Fix decoding of encoding message --- src/server.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/server.c b/src/server.c index f52a197..2800ade 100644 --- a/src/server.c +++ b/src/server.c @@ -524,8 +524,10 @@ static int on_client_set_encodings(struct nvnc_client *client) int n_encodings = MIN(MAX_ENCODINGS, ntohs(msg->n_encodings)); int n = 0; - for (int i = 0; i < n_encodings; ++i) - switch (msg->encodings[i]) { + for (int i = 0; i < n_encodings; ++i) { + enum rfb_encodings encoding = htonl(msg->encodings[i]); + + switch (encoding) { case RFB_ENCODING_RAW: case RFB_ENCODING_COPYRECT: case RFB_ENCODING_RRE: @@ -534,8 +536,9 @@ static int on_client_set_encodings(struct nvnc_client *client) case RFB_ENCODING_ZRLE: case RFB_ENCODING_CURSOR: case RFB_ENCODING_DESKTOPSIZE: - client->encodings[n++] = msg->encodings[i]; + client->encodings[n++] = encoding; } + } client->n_encodings = n;