The call to nfc_free is not needed because when calloc fails ctx will be
NULL and nfc_free will do nothing, when fido_nl_new() fails ctx->nl will
be null and does not need to be freed.
Additionally ctx->fd is 0 (due to calloc zero-initializing ctx) and
should not be closed.
Therefore I replaced this with a free call to just undo the (potential)
allocation by calloc.
Signed-off-by: Tobias Wiese <tobias@tobiaswiese.com>
If we send an APDU without enough time to also read the response, the
next `fido_dev_*()` call may fail spuriously due to there being data
left to read on the bus. To prevent this to the best of our abilities,
enforce a minimum remaining timeout for each `fido_{tx,rx}()` pair.
The exception to this rule is the selection algorithms which are left
the application is responsible for pacing in a sensible manner (the
transaction happens across multiple function calls).
If an application finds itself in a broken state, it can recover by
requesting a new channel ID via closing and re-opening the `fido_dev_t`.
This resolves#917.
https://editorconfig.org/ is supported out of the box by many text
editors, defining a consistent set of settings to facilitate maintaining
consistent coding styles. Additionally, GitHub's renderer honors these
styles (otherwise defaulting to 4 space tabs) which helps in review
stages.