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

- CS104 connection: Fix use-after-free in handleConnection() (see #61) #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

S-trace
Copy link

@S-trace S-trace commented Nov 18, 2019

If user calls CS104_Connection_destroy() in connectionHandler() on CONNECTION_CLOSED event -
two memory errors will occur in handleConnection() because self is not valid anymore
(after returning from connectionHandler() which called CS104_Connection_destroy() before):

(cs104_connection.c:817) Socket_destroy(self->socket);
(cs104_connection.c:821) self->running = false;

So, it's necessary to call connectionHandler() with CONNECTION_CLOSED event right before exiting
from handleConnection().

Fixes #61

If user calls CS104_Connection_destroy() in connectionHandler() on CONNECTION_CLOSED event -
two memory errors will occur in handleConnection() because self is not valid anymore
(after returning from connectionHandler() which called CS104_Connection_destroy() before):

(cs104_connection.c:817) Socket_destroy(self->socket);
(cs104_connection.c:821) self->running = false;

So, it's necessary to call connectionHandler() with CONNECTION_CLOSED event right before exiting
from handleConnection().

Fixes #61
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.

Use after free in handleConnection (cs104_connection.c:821)
1 participant