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

Fix use-after-free and concurrent access segmentation fault #238

Merged
merged 3 commits into from
Jan 6, 2019

Conversation

Quentin01
Copy link
Contributor

  • Correctly iterate over the clients without using freed memory. (See Use-after-free issue in rfbShutdownServer #211)
  • Fix a concurrent issue between the thread doing the shutdown that will free the client and the thread of clientOutput that will access it.

See #212 for more informations.

PS: It's really hard to make a tiny PR because of the indentation issues everywhere, you should probably do something about that :)

@bk138
Copy link
Member

bk138 commented Aug 12, 2018

Thanks! Will review ASAP, time permitting.

@bk138 bk138 self-assigned this Oct 1, 2018
if(cl->screen->backgroundLoop)
pthread_create(&cl->client_thread, NULL, clientInput, (void *)cl);
if(cl->screen->backgroundLoop) {
pipe(cl->pipe_notify_client_thread);
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be nice to check the return value of pipe(), and perhaps set cl->pipe_notify_client_thread[0] and cl->pipe_notify_client_thread[1] to -1 if it fails? Because the current code will try to read and write from arbitrary file descriptors, and will also end up closing them, if pipe() failed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will change that ASAP. Thanks for the review and sorry for the delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants