scd: Fix "Conflicting usage" bug.
authorNIIBE Yutaka <gniibe@fsij.org>
Thu, 3 Dec 2015 02:26:24 +0000 (11:26 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Tue, 15 Dec 2015 00:48:06 +0000 (09:48 +0900)
commit9934889415d47f691344499972a0b879cf90ff96
treeda08cabd416497d2ea5fbf91dd8dc534cf7edcd7
parent01fa4c7b8b821da21a5acdeaeeafdd8c78a7a7cd
scd: Fix "Conflicting usage" bug.

* scd/apdu.c (apdu_close_reader): Call CLOSE_READER method even if we
  got an error from apdu_disconnect.
* scd/app-common.h (no_reuse): Remove.
* scd/app.c (application_notify_card_reset): Deallocate APP here.
(select_application, release_application): Don't use NO_REUSE.

--

Reproducible scenario: Invoke gpg --card-edit session from a terminal.
Invoke another gpg --card-edit session from another.  Remove a token.
Insert a token again.  Type RET on both terminals.  One of terminal
answers "Conflicting usage".

Perhaps, having NO_REUSE field was to avoid race conditions.  Now,
APP can be safely deallocated by application_notify_card_reset.

Thanks to the2nd.

(backport of commit f42c50dbf00c2e6298ca6830cbe6d36805fa54a3)
scd/apdu.c
scd/app-common.h
scd/app.c