summaryrefslogtreecommitdiff
path: root/sshconnect2.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2003-10-15 15:55:59 +1000
committerDarren Tucker <dtucker@zip.com.au>2003-10-15 15:55:59 +1000
commitd05b60189552bb2746a069d0d320b0ee64df06e1 (patch)
tree96f70d91780122cf99ee15ff2e01cbca6ad9f07e /sshconnect2.c
parent0a118da00eff14f018a055b3c187f27aa7d78ecd (diff)
downloadopenssh-git-d05b60189552bb2746a069d0d320b0ee64df06e1.tar.gz
- markus@cvs.openbsd.org 2003/10/11 08:26:43
[sshconnect2.c] search keys in reverse order; fixes #684
Diffstat (limited to 'sshconnect2.c')
-rw-r--r--sshconnect2.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sshconnect2.c b/sshconnect2.c
index 2ef4201c..f38fdf9a 100644
--- a/sshconnect2.c
+++ b/sshconnect2.c
@@ -23,7 +23,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshconnect2.c,v 1.126 2003/10/07 21:58:28 deraadt Exp $");
+RCSID("$OpenBSD: sshconnect2.c,v 1.127 2003/10/11 08:26:43 markus Exp $");
#include "openbsd-compat/sys-queue.h"
@@ -453,7 +453,12 @@ input_userauth_pk_ok(int type, u_int32_t seq, void *ctxt)
debug2("input_userauth_pk_ok: fp %s", fp);
xfree(fp);
- TAILQ_FOREACH(id, &authctxt->keys, next) {
+ /*
+ * search keys in the reverse order, because last candidate has been
+ * moved to the end of the queue. this also avoids confusion by
+ * duplicate keys
+ */
+ TAILQ_FOREACH_REVERSE(id, &authctxt->keys, next, idlist) {
if (key_equal(key, id->key)) {
sent = sign_and_send_pubkey(authctxt, id);
break;
@@ -1086,6 +1091,7 @@ userauth_pubkey(Authctxt *authctxt)
while ((id = TAILQ_FIRST(&authctxt->keys))) {
if (id->tried++)
return (0);
+ /* move key to the end of the queue */
TAILQ_REMOVE(&authctxt->keys, id, next);
TAILQ_INSERT_TAIL(&authctxt->keys, id, next);
/*