mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2024-11-08 01:04:43 +01:00
Bugfix/kasm 1912 websocket crash (#57)
* Copy-paste bug in SSE2 scaling to under 0.5x * Better handling of websocket frames * KASM-1912 websocket crash, scaling bug Co-authored-by: Lauri Kasanen <cand@gmx.com> Co-authored-by: matt <matt@kasmweb.com>
This commit is contained in:
parent
dd26c40844
commit
93e47e5d54
@ -44,11 +44,11 @@ static void do_proxy(ws_ctx_t *ws_ctx, int target) {
|
||||
int maxfd, client = ws_ctx->sockfd;
|
||||
unsigned int opcode, left, ret;
|
||||
unsigned int tout_start, tout_end, cout_start, cout_end;
|
||||
unsigned int tin_start, tin_end;
|
||||
unsigned int tin_end;
|
||||
ssize_t len, bytes;
|
||||
|
||||
tout_start = tout_end = cout_start = cout_end =
|
||||
tin_start = tin_end = 0;
|
||||
tin_end = 0;
|
||||
maxfd = client > target ? client+1 : target+1;
|
||||
|
||||
while (1) {
|
||||
@ -165,7 +165,7 @@ static void do_proxy(ws_ctx_t *ws_ctx, int target) {
|
||||
}
|
||||
|
||||
if (FD_ISSET(client, &rlist)) {
|
||||
bytes = ws_recv(ws_ctx, ws_ctx->tin_buf + tin_end, BUFSIZE-1);
|
||||
bytes = ws_recv(ws_ctx, ws_ctx->tin_buf + tin_end, BUFSIZE-1-tin_end);
|
||||
if (pipe_error) { break; }
|
||||
if (bytes <= 0) {
|
||||
handler_emsg("client closed connection\n");
|
||||
@ -180,13 +180,13 @@ static void do_proxy(ws_ctx_t *ws_ctx, int target) {
|
||||
printf("\n");
|
||||
*/
|
||||
if (ws_ctx->hybi) {
|
||||
len = decode_hybi(ws_ctx->tin_buf + tin_start,
|
||||
tin_end-tin_start,
|
||||
len = decode_hybi(ws_ctx->tin_buf,
|
||||
tin_end,
|
||||
ws_ctx->tout_buf, BUFSIZE-1,
|
||||
&opcode, &left);
|
||||
} else {
|
||||
len = decode_hixie(ws_ctx->tin_buf + tin_start,
|
||||
tin_end-tin_start,
|
||||
len = decode_hixie(ws_ctx->tin_buf,
|
||||
tin_end,
|
||||
ws_ctx->tout_buf, BUFSIZE-1,
|
||||
&opcode, &left);
|
||||
}
|
||||
@ -208,10 +208,13 @@ static void do_proxy(ws_ctx_t *ws_ctx, int target) {
|
||||
break;
|
||||
}
|
||||
if (left) {
|
||||
tin_start = tin_end - left;
|
||||
//printf("partial frame from client");
|
||||
const unsigned tin_start = tin_end - left;
|
||||
//handler_emsg("partial frame from client, %u left, start %u end %u, lens %lu %lu\n",
|
||||
// left, tin_start, tin_end, bytes, len);
|
||||
memmove(ws_ctx->tin_buf, ws_ctx->tin_buf + tin_start, left);
|
||||
tin_end = left;
|
||||
} else {
|
||||
tin_start = 0;
|
||||
//handler_emsg("handled %lu/%lu bytes\n", bytes, len);
|
||||
tin_end = 0;
|
||||
}
|
||||
|
||||
|
@ -1024,7 +1024,7 @@ PixelBuffer *rfb::progressiveBilinearScale(const PixelBuffer *pb,
|
||||
rdr::U8 *newpx = ((ManagedPixelBuffer *) newpb)->getBufferRW(newpb->getRect(),
|
||||
&newstride);
|
||||
|
||||
SSE2_scale(oldpx, tgtw, tgth, newpx, oldstride, newstride, tgtdiff);
|
||||
SSE2_scale(oldpx, tgtw, tgth, newpx, oldstride, newstride, tgtw / (float) oldw);
|
||||
if (del)
|
||||
delete pb;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user