fido2: plug some resource leaks in the client - #781
Conversation
|
Thanks for the PR! Alternatively, we could also just iterate device descriptors and only connect to the devices that match our selector, like here: What do you think? |
Yes, good point. I see that still implies a transient open() in fido2.hid, but it's much cleaner here and in consumers if they can just filter the list without worrying as much about what they're discarding. I'll take a look at what that means for consumers of the API, but it seems like it will probably Just Work(TM) as long as |
The main target here is list_ctaphid_devices: on FreeBSD, this actually breaks `nitropy list` because our uhid/u2f drivers won't allow a second open() of the device. The devices that *do not* match will leak the fd, so later _list() calls (or at least the Nitrokey 3 one) cannot enumerate them at all. find_device() has the same leak in the path that finds one device by serial, so that path is altered to similarly open the connection only after applying our filtering. Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
|
I don't have a device that can use the fido2 client on-hand, so the find_device() part is untested. I realized after writing my last comment that |
The main target here is list_ctaphid_devices: on FreeBSD, this actually breaks
nitropy listbecause our uhid/u2f drivers won't allow a second open() of the device. The devices that do not match will leak the fd, so later _list() calls (or at least the Nitrokey 3 one) cannot enumerate them at all.filtered_devices() was split out to trivially plug the same leak in find_device().
Apologies in advance if my style/wrapping is atrocious, I only get to write python a little bit every few years.