diff options
author | NIIBE Yutaka <[email protected]> | 2015-12-03 02:26:24 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2015-12-03 02:26:24 +0000 |
commit | f42c50dbf00c2e6298ca6830cbe6d36805fa54a3 (patch) | |
tree | 1526b6169578ab61d7fc6b945cae265b5b51854f /scd/app.c | |
parent | scd: Fix for Curve25519 prefix handling. (diff) | |
download | gnupg-f42c50dbf00c2e6298ca6830cbe6d36805fa54a3.tar.gz gnupg-f42c50dbf00c2e6298ca6830cbe6d36805fa54a3.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | scd/app.c | 27 |
1 files changed, 6 insertions, 21 deletions
@@ -175,9 +175,12 @@ application_notify_card_reset (int slot) /* FIXME: We are ignoring any error value here. */ lock_reader (slot, NULL); - /* Mark application as non-reusable. */ + /* Release the APP, as it's not reusable any more. */ if (lock_table[slot].app) - lock_table[slot].app->no_reuse = 1; + { + deallocate_app (lock_table[slot].app); + lock_table[slot].app = NULL; + } /* Deallocate a saved application for that slot, so that we won't try to reuse it. If there is no saved application, set a flag so @@ -251,16 +254,6 @@ select_application (ctrl_t ctrl, int slot, const char *name, app_t *r_app) return gpg_error (GPG_ERR_CONFLICT); } - /* Don't use a non-reusable marked application. */ - if (app && app->no_reuse) - { - unlock_reader (slot); - log_info ("lingering application '%s' in use by reader %d" - " - can't switch\n", - app->apptype? app->apptype:"?", slot); - return gpg_error (GPG_ERR_CONFLICT); - } - /* If we don't have an app, check whether we have a saved application for that slot. This is useful so that a card does not get reset even if only one session is using the card - this @@ -495,15 +488,7 @@ release_application (app_t app) if (lock_table[slot].last_app) deallocate_app (lock_table[slot].last_app); - if (app->no_reuse) - { - /* If we shall not re-use the application we can't save it for - later use. */ - deallocate_app (app); - lock_table[slot].last_app = NULL; - } - else - lock_table[slot].last_app = lock_table[slot].app; + lock_table[slot].last_app = lock_table[slot].app; lock_table[slot].app = NULL; unlock_reader (slot); } |