{commands,start}: remove element from list first

First remove the client from the list then close the fd. Otherwise we open ourselves to a race where another codepath might be writing to a bad file descriptor. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 96f0cf3b
...@@ -1021,8 +1021,8 @@ static void lxc_cmd_fd_cleanup(int fd, struct lxc_handler *handler, ...@@ -1021,8 +1021,8 @@ static void lxc_cmd_fd_cleanup(int fd, struct lxc_handler *handler,
continue; continue;
/* kick client from list */ /* kick client from list */
close(client->clientfd);
lxc_list_del(cur); lxc_list_del(cur);
close(client->clientfd);
free(cur->elem); free(cur->elem);
free(cur); free(cur);
/* No need to walk the whole list. If we found the state client /* No need to walk the whole list. If we found the state client
......
...@@ -418,8 +418,8 @@ int lxc_serve_state_clients(const char *name, struct lxc_handler *handler, ...@@ -418,8 +418,8 @@ int lxc_serve_state_clients(const char *name, struct lxc_handler *handler,
} }
/* kick client from list */ /* kick client from list */
close(client->clientfd);
lxc_list_del(cur); lxc_list_del(cur);
close(client->clientfd);
free(cur->elem); free(cur->elem);
free(cur); free(cur);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment