|
|
ae49b1 |
From 93fd4bc18a81a568f3329ee2aa22390ef75b05ed Mon Sep 17 00:00:00 2001
|
|
|
ae49b1 |
From: plettix <plettix@gmail.com>
|
|
|
ae49b1 |
Date: Tue, 7 Jul 2015 10:32:16 +0200
|
|
|
ae49b1 |
Subject: [PATCH 2/3] fix for issue 81 use different buffers for decode and
|
|
|
ae49b1 |
encode
|
|
|
ae49b1 |
|
|
|
ae49b1 |
---
|
|
|
ae49b1 |
libvncserver/websockets.c | 19 ++++++++++---------
|
|
|
ae49b1 |
1 file changed, 10 insertions(+), 9 deletions(-)
|
|
|
ae49b1 |
|
|
|
ae49b1 |
diff --git a/libvncserver/websockets.c b/libvncserver/websockets.c
|
|
|
ae49b1 |
index 937f6d4d..3c8e99aa 100644
|
|
|
ae49b1 |
--- a/libvncserver/websockets.c
|
|
|
ae49b1 |
+++ b/libvncserver/websockets.c
|
|
|
ae49b1 |
@@ -481,15 +481,15 @@ webSocketsEncodeHixie(rfbClientPtr cl, const char *src, int len, char **dst)
|
|
|
ae49b1 |
int sz = 0;
|
|
|
ae49b1 |
ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx;
|
|
|
ae49b1 |
|
|
|
ae49b1 |
- wsctx->codeBuf[sz++] = '\x00';
|
|
|
ae49b1 |
- len = __b64_ntop((unsigned char *)src, len, wsctx->codeBuf+sz, sizeof(wsctx->codeBuf) - (sz + 1));
|
|
|
ae49b1 |
+ wsctx->codeBufEncode[sz++] = '\x00';
|
|
|
ae49b1 |
+ len = __b64_ntop((unsigned char *)src, len, wsctx->codeBufEncode+sz, sizeof(wsctx->codeBufEncode) - (sz + 1));
|
|
|
ae49b1 |
if (len < 0) {
|
|
|
ae49b1 |
return len;
|
|
|
ae49b1 |
}
|
|
|
ae49b1 |
sz += len;
|
|
|
ae49b1 |
|
|
|
ae49b1 |
- wsctx->codeBuf[sz++] = '\xff';
|
|
|
ae49b1 |
- *dst = wsctx->codeBuf;
|
|
|
ae49b1 |
+ wsctx->codeBufEncode[sz++] = '\xff';
|
|
|
ae49b1 |
+ *dst = wsctx->codeBufEncode;
|
|
|
ae49b1 |
return sz;
|
|
|
ae49b1 |
}
|
|
|
ae49b1 |
|
|
|
ae49b1 |
@@ -527,7 +527,7 @@ webSocketsDecodeHixie(rfbClientPtr cl, char *dst, int len)
|
|
|
ae49b1 |
char *buf, *end = NULL;
|
|
|
ae49b1 |
ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx;
|
|
|
ae49b1 |
|
|
|
ae49b1 |
- buf = wsctx->codeBuf;
|
|
|
ae49b1 |
+ buf = wsctx->codeBufDecode;
|
|
|
ae49b1 |
|
|
|
ae49b1 |
n = ws_peek(cl, buf, len*2+2);
|
|
|
ae49b1 |
|
|
|
ae49b1 |
@@ -781,7 +781,7 @@ webSocketsEncodeHybi(rfbClientPtr cl, const char *src, int len, char **dst)
|
|
|
ae49b1 |
return 0;
|
|
|
ae49b1 |
}
|
|
|
ae49b1 |
|
|
|
ae49b1 |
- header = (ws_header_t *)wsctx->codeBuf;
|
|
|
ae49b1 |
+ header = (ws_header_t *)wsctx->codeBufEncode;
|
|
|
ae49b1 |
|
|
|
ae49b1 |
if (wsctx->base64) {
|
|
|
ae49b1 |
opcode = WS_OPCODE_TEXT_FRAME;
|
|
|
ae49b1 |
@@ -806,7 +806,7 @@ webSocketsEncodeHybi(rfbClientPtr cl, const char *src, int len, char **dst)
|
|
|
ae49b1 |
}
|
|
|
ae49b1 |
|
|
|
ae49b1 |
if (wsctx->base64) {
|
|
|
ae49b1 |
- if (-1 == (ret = __b64_ntop((unsigned char *)src, len, wsctx->codeBuf + sz, sizeof(wsctx->codeBuf) - sz))) {
|
|
|
ae49b1 |
+ if (-1 == (ret = __b64_ntop((unsigned char *)src, len, wsctx->codeBufEncode + sz, sizeof(wsctx->codeBufEncode) - sz))) {
|
|
|
ae49b1 |
rfbErr("%s: Base 64 encode failed\n", __func__);
|
|
|
ae49b1 |
} else {
|
|
|
ae49b1 |
if (ret != blen)
|
|
|
ae49b1 |
@@ -814,11 +814,12 @@ webSocketsEncodeHybi(rfbClientPtr cl, const char *src, int len, char **dst)
|
|
|
ae49b1 |
ret += sz;
|
|
|
ae49b1 |
}
|
|
|
ae49b1 |
} else {
|
|
|
ae49b1 |
- memcpy(wsctx->codeBuf + sz, src, len);
|
|
|
ae49b1 |
+ memcpy(wsctx->codeBufEncode + sz, src, len);
|
|
|
ae49b1 |
ret = sz + len;
|
|
|
ae49b1 |
}
|
|
|
ae49b1 |
|
|
|
ae49b1 |
- *dst = wsctx->codeBuf;
|
|
|
ae49b1 |
+ *dst = wsctx->codeBufEncode;
|
|
|
ae49b1 |
+
|
|
|
ae49b1 |
return ret;
|
|
|
ae49b1 |
}
|
|
|
ae49b1 |
|
|
|
ae49b1 |
--
|
|
|
ae49b1 |
2.26.2
|
|
|
ae49b1 |
|