From 91f6347485a2efe714cf0bc50e4d1fbc2a33c01e Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 27 Apr 2015 22:42:10 +0000 Subject: [PATCH 1/3] Assign to the right variable when comparing clients. --- cmd-find.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd-find.c b/cmd-find.c index a71968a1..14124a36 100644 --- a/cmd-find.c +++ b/cmd-find.c @@ -131,7 +131,7 @@ cmd_find_best_client(struct client **clist, u_int csize) } else { TAILQ_FOREACH(c_loop, &clients, entry) { if (cmd_find_client_better(c_loop, c)) - c_loop = c; + c = c_loop; } } return (c); From b7777e7ef37a6a5b9a231602c1ac66a307ae23db Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 27 Apr 2015 22:50:35 +0000 Subject: [PATCH 2/3] Reset cfg_ncauses to 0 as well or we could allocate the wrong size if called again. --- cfg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cfg.c b/cfg.c index bacec996..8b44ce24 100644 --- a/cfg.c +++ b/cfg.c @@ -140,6 +140,7 @@ cfg_print_causes(struct cmd_q *cmdq) free(cfg_causes); cfg_causes = NULL; + cfg_ncauses = 0; } void @@ -161,4 +162,5 @@ cfg_show_causes(struct session *s) free(cfg_causes); cfg_causes = NULL; + cfg_ncauses = 0; } From c2bc84aa4dd30c46930994321de0541edf6a30e9 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 27 Apr 2015 22:58:58 +0000 Subject: [PATCH 3/3] Do not include unattached clients when trying to find one for target. --- cmd-find.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd-find.c b/cmd-find.c index 14124a36..f7c1ba74 100644 --- a/cmd-find.c +++ b/cmd-find.c @@ -125,11 +125,15 @@ cmd_find_best_client(struct client **clist, u_int csize) c = NULL; if (clist != NULL) { for (i = 0; i < csize; i++) { + if (clist[i]->session == NULL) + continue; if (cmd_find_client_better(clist[i], c)) c = clist[i]; } } else { TAILQ_FOREACH(c_loop, &clients, entry) { + if (c_loop->session == NULL) + continue; if (cmd_find_client_better(c_loop, c)) c = c_loop; }