Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuous updates extension from TurboVNC #557

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
libvncserver/sockets: skip
Volodymyr Samokhatko committed Mar 16, 2023
commit c06e76c77956d510af6328ed209a1a85b99f2c42
28 changes: 28 additions & 0 deletions src/libvncserver/sockets.c
Original file line number Diff line number Diff line change
@@ -794,6 +794,34 @@ int rfbReadExact(rfbClientPtr cl,char* buf,int len)
return(rfbReadExactTimeout(cl,buf,len,rfbMaxClientWait));
}

inline static unsigned min(unsigned a, unsigned b)
{
return a > b ? b : a;
}

/*
* SkipExact reads an exact number of bytes on a TCP socket into a temporary
* buffer and then discards them. Returns 1 on success, 0 if the other end has
* closed, or -1 if an error occurred (errno is set to ETIMEDOUT if it timed
* out).
*/

int rfbSkipExact(rfbClientPtr cl, int len)
{
char *tmpbuf = NULL;
int bufLen = min(len, 65536), i, retval = 1;

tmpbuf = (char *)malloc(bufLen);

for (i = 0; i < len; i += bufLen) {
retval = rfbReadExact(cl, tmpbuf, min(bufLen, len - i));
if (retval <= 0) break;
}

free(tmpbuf);
return retval;
}

/*
* PeekExact peeks at an exact number of bytes from a client. Returns 1 if
* those bytes have been read, 0 if the other end has closed, or -1 if an