[git] GnuPG - branch, master, updated. gnupg-2.1.9-213-gf42c50d

by NIIBE Yutaka cvs at cvs.gnupg.org
Thu Dec 3 03:36:00 CET 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  f42c50dbf00c2e6298ca6830cbe6d36805fa54a3 (commit)
      from  11b2691eddc42e91651e4f95dd2731255a3e9211 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f42c50dbf00c2e6298ca6830cbe6d36805fa54a3
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Thu Dec 3 11:26:24 2015 +0900

    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.

diff --git a/scd/apdu.c b/scd/apdu.c
index eb3d4b6..95a2561 100644
--- a/scd/apdu.c
+++ b/scd/apdu.c
@@ -3215,9 +3215,12 @@ apdu_close_reader (int slot)
   sw = apdu_disconnect (slot);
   if (sw)
     {
+      /*
+       * When the reader/token was removed it might come here.
+       * It should go through to call CLOSE_READER even if we got an error.
+       */
       if (DBG_READER)
-        log_debug ("leave: apdu_close_reader => 0x%x (apdu_disconnect)\n", sw);
-      return sw;
+        log_debug ("apdu_close_reader => 0x%x (apdu_disconnect)\n", sw);
     }
   if (reader_table[slot].close_reader)
     {
diff --git a/scd/app-common.h b/scd/app-common.h
index 379bcd1..b4bb55b 100644
--- a/scd/app-common.h
+++ b/scd/app-common.h
@@ -47,11 +47,6 @@ struct app_ctx_s {
      operations the particular function pointer is set to NULL */
   unsigned int ref_count;
 
-  /* Flag indicating that a reset has been done for that application
-     and that this context is merely lingering and just should not be
-     reused.  */
-  int no_reuse;
-
   /* Used reader slot. */
   int slot;
 
diff --git a/scd/app.c b/scd/app.c
index 49e08e6..5e6751e 100644
--- a/scd/app.c
+++ b/scd/app.c
@@ -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);
 }

-----------------------------------------------------------------------

Summary of changes:
 scd/apdu.c       |  7 +++++--
 scd/app-common.h |  5 -----
 scd/app.c        | 27 ++++++---------------------
 3 files changed, 11 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list