diff options
author | Gernot Tenchio <gernot.tenchio@securepoint.de> | 2011-08-29 08:53:41 +0200 |
---|---|---|
committer | Gernot Tenchio <gernot.tenchio@securepoint.de> | 2011-08-29 08:53:41 +0200 |
commit | 0f2ac00f6ee8102c3695f40a1896edff7c54fbd5 (patch) | |
tree | eefb85b0086416425da7783fb39a58ddc75a4203 /libvncserver | |
parent | b16e8c2afb1d7dd17cf8349412ad5e92998b5a60 (diff) | |
download | libtdevnc-0f2ac00f6ee8102c3695f40a1896edff7c54fbd5.tar.gz libtdevnc-0f2ac00f6ee8102c3695f40a1896edff7c54fbd5.zip |
websockets: use 32bit Xor in webSocketsDecodeHybi()
Diffstat (limited to 'libvncserver')
-rwxr-xr-x | libvncserver/websockets.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libvncserver/websockets.c b/libvncserver/websockets.c index 0cce3c9..cec2230 100755 --- a/libvncserver/websockets.c +++ b/libvncserver/websockets.c @@ -626,11 +626,12 @@ static int webSocketsDecodeHybi(rfbClientPtr cl, char *dst, int len) { char *buf, *payload; + uint32_t *payload32; int ret = -1, result = -1; int total = 0; ws_mask_t mask; ws_header_t *header; - int i, j; + int i; unsigned char opcode; ws_ctx_t *wsctx = (ws_ctx_t *)cl->wsctx; int flength, fin, fhlen; @@ -714,10 +715,14 @@ webSocketsDecodeHybi(rfbClientPtr cl, char *dst, int len) buf[ret] = '\0'; } - /* process 1 frame */ - for (i = 0; i < flength; i++) { - j = i % 4; - payload[i] ^= mask.c[j]; + /* process 1 frame (32 bit op) */ + payload32 = (uint32_t *)payload; + for (i = 0; i < flength / 4; i++) { + payload32[i] ^= mask.u; + } + /* process the remaining bytes (if any) */ + for (i*=4; i < flength; i++) { + payload[i] ^= mask.c[i % 4]; } switch (opcode) { |