diff options
author | djm@openbsd.org <djm@openbsd.org> | 2020-08-27 09:43:28 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2020-08-27 19:47:35 +1000 |
commit | b969072cc3d62d05cb41bc6d6f3c22c764ed932f (patch) | |
tree | 22337c68ccecdca53b8228b11c9352a72ffd97fd /sk-usbhid.c | |
parent | 744df42a129d7d7db26947b7561be32edac89f88 (diff) |
upstream: skip a bit more FIDO token selection logic when only a
single token is attached.
with Pedro Martelletto
OpenBSD-Commit-ID: e4a324bd9814227ec1faa8cb619580e661cca9ac
Diffstat (limited to 'sk-usbhid.c')
-rw-r--r-- | sk-usbhid.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sk-usbhid.c b/sk-usbhid.c index 0b11e40a..98e8ccf1 100644 --- a/sk-usbhid.c +++ b/sk-usbhid.c @@ -367,8 +367,13 @@ sk_select_by_cred(const fido_dev_info_t *devlist, size_t ndevs, skdebug(__func__, "sk_openv failed"); return NULL; } + if (skvcnt == 1) { + sk = skv[0]; + skv[0] = NULL; + goto out; + } sk = NULL; - for (i = 0; i < skvcnt; i++) + for (i = 0; i < skvcnt; i++) { if (sk_try(skv[i], application, key_handle, key_handle_len) == 0) { sk = skv[i]; @@ -376,6 +381,8 @@ sk_select_by_cred(const fido_dev_info_t *devlist, size_t ndevs, skdebug(__func__, "found key in %s", sk->path); break; } + } + out: sk_closev(skv, skvcnt); return sk; } |