diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2003-10-11 08:26:44 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2003-10-11 08:26:44 +0000 |
commit | ee0558908eceb869d00454a0c88c3eff9c1e7cf6 (patch) | |
tree | b8b7972001972ed25e0a7d48f18bc6e8fba7768b | |
parent | 71c688d733c6338fddc0b48a555c52b7b407c840 (diff) |
search keys in reverse order; fixes #684
-rw-r--r-- | usr.bin/ssh/sshconnect2.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/ssh/sshconnect2.c b/usr.bin/ssh/sshconnect2.c index 9102031fc8f..a17efccdbc4 100644 --- a/usr.bin/ssh/sshconnect2.c +++ b/usr.bin/ssh/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 "ssh.h" #include "ssh2.h" @@ -451,7 +451,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; @@ -1084,6 +1089,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); /* |