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

sockets.c: Destinct pointers for restrict parameters #602

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
4 changes: 3 additions & 1 deletion src/libvncserver/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ rfbReadExactTimeout(rfbClientPtr cl, char* buf, int len, int timeout)
rfbSocket sock = cl->sock;
int n;
fd_set fds;
fd_set exceptfds;
struct timeval tv;

while (len > 0) {
Expand Down Expand Up @@ -715,9 +716,10 @@ rfbReadExactTimeout(rfbClientPtr cl, char* buf, int len, int timeout)
#endif
FD_ZERO(&fds);
FD_SET(sock, &fds);
exceptfds = fds;
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
n = select(sock+1, &fds, NULL, &fds, &tv);
n = select(sock+1, &fds, NULL, &exceptfds, &tv);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…and if select() sets a bit in exceptfds where is it checked in the following code?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I might have missed something there, but afaict nobody is checking fds currently.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I am not familiar with the semantics of select() here, but wouldn't it be the same as passing NULL if the caller is not interested in the file descriptors anyway?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the manpage, NULL is equivalent to an empty set. So this is different, as it specifies a set with one fd set.

Regarding the checking of the result of select(): I can not claim to fully understand the code, but only a single fd is set in fds (FD_SET(sock, &fds);). I guess this fd is probed afterwards, so that the result of select() is not needed.

if (n < 0) {
rfbLogPerror("ReadExact: select");
return n;
Expand Down
Loading