Commit 9e379835 authored by Matt Johnston's avatar Matt Johnston
Browse files

avoid invalidated iterator when connection fails

parent 8ccbd216
......@@ -174,28 +174,26 @@ void remove_connect_pending() {
void set_connect_fds(fd_set *writefd) {
m_list_elem *iter;
TRACE(("enter handle_connect_fds"))
for (iter = ses.conn_pending.first; iter; iter = iter->next) {
TRACE(("enter set_connect_fds"))
iter = ses.conn_pending.first;
while (iter) {
m_list_elem *next_iter = iter->next;
struct dropbear_progress_connection *c = iter->item;
/* Set one going */
while (c->res_iter && c->sock < 0)
{
while (c->res_iter && c->sock < 0) {
connect_try_next(c);
}
if (c->sock >= 0) {
FD_SET(c->sock, writefd);
} else {
m_list_elem *remove_iter;
/* Final failure */
if (!c->errstring) {
c->errstring = m_strdup("unexpected failure");
}
c->cb(DROPBEAR_FAILURE, -1, c->cb_data, c->errstring);
/* Safely remove without invalidating iter */
remove_iter = iter;
iter = iter->prev;
remove_connect(c, remove_iter);
remove_connect(c, iter);
}
iter = next_iter;
}
}
......
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