[git] GnuPG - branch, master, updated. gnupg-2.1.18-29-g7c8eee4

by NIIBE Yutaka cvs at cvs.gnupg.org
Mon Jan 30 01:08:10 CET 2017


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  7c8eee4d396a751d41fd1ee1e1b87b851fca172a (commit)
       via  216afba0d99582d0fbae1d6e925f4ddb349d9de3 (commit)
      from  f3d9b2582bcaa1936b4fed5ec42a889b02df2f42 (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 7c8eee4d396a751d41fd1ee1e1b87b851fca172a
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Mon Jan 30 09:05:37 2017 +0900

    scd: Don't send GET_STATUS packet if not needed.
    
    * scd/apdu.c (apdu_get_status_internal): Add ON_WIRE arg.
    (apdu_connect): Call apdu_get_status_internal with ON_WIRE enabled.
    (apdu_get_status): For periodical check, call apdu_get_status_internal
    with ON_WIRE disabled.
    
    Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>

diff --git a/scd/apdu.c b/scd/apdu.c
index 0037c47..f752284 100644
--- a/scd/apdu.c
+++ b/scd/apdu.c
@@ -367,8 +367,8 @@ long (* DLSTDCALL pcsc_control) (long card,
 static int pcsc_vendor_specific_init (int slot);
 static int pcsc_get_status (int slot, unsigned int *status);
 static int reset_pcsc_reader (int slot);
-static int apdu_get_status_internal (int slot, int hang, int no_atr_reset,
-                                     unsigned int *status);
+static int apdu_get_status_internal (int slot, int hang, unsigned int *status,
+                                     int on_wire);
 static int check_pcsc_pinpad (int slot, int command, pininfo_t *pininfo);
 static int pcsc_pinpad_verify (int slot, int class, int ins, int p0, int p1,
                                pininfo_t *pininfo);
@@ -3386,7 +3386,7 @@ apdu_connect (int slot)
      Without that we would force a reset of the card with the next
      call to apdu_get_status.  */
   if (!sw)
-    sw = apdu_get_status_internal (slot, 1, 1, &status);
+    sw = apdu_get_status_internal (slot, 1, &status, 1);
 
   if (sw)
     ;
@@ -3551,11 +3551,10 @@ apdu_get_atr (int slot, size_t *atrlen)
      APDU_CARD_ACTIVE  (bit 2) = card active
                        (bit 3) = card access locked [not yet implemented]
 
-   For must applications, testing bit 0 is sufficient.
+   For most applications, testing bit 0 is sufficient.
 */
 static int
-apdu_get_status_internal (int slot, int hang, int no_atr_reset,
-                          unsigned int *status)
+apdu_get_status_internal (int slot, int hang, unsigned int *status, int on_wire)
 {
   int sw;
   unsigned int s;
@@ -3566,6 +3565,18 @@ apdu_get_status_internal (int slot, int hang, int no_atr_reset,
   if ((sw = hang? lock_slot (slot) : trylock_slot (slot)))
     return sw;
 
+  /* If the card (with its lower-level driver) doesn't require
+     GET_STATUS on wire (because it supports INTERRUPT transfer for
+     status change, or it's a token which has a card always inserted),
+     no need to send on wire.  */
+  if (!on_wire && !reader_table[slot].require_get_status)
+    {
+      unlock_slot (slot);
+      if (status)
+        *status = (APDU_CARD_USABLE|APDU_CARD_ACTIVE);
+      return 0;
+    }
+
   if (reader_table[slot].get_status_reader)
     sw = reader_table[slot].get_status_reader (slot, &s);
 
@@ -3573,7 +3584,7 @@ apdu_get_status_internal (int slot, int hang, int no_atr_reset,
 
   if (sw)
     {
-      if (!no_atr_reset)
+      if (on_wire)
         reader_table[slot].atrlen = 0;
       s = 0;
     }
@@ -3592,7 +3603,7 @@ apdu_get_status (int slot, int hang, unsigned int *status)
 
   if (DBG_READER)
     log_debug ("enter: apdu_get_status: slot=%d hang=%d\n", slot, hang);
-  sw = apdu_get_status_internal (slot, hang, 0, status);
+  sw = apdu_get_status_internal (slot, hang, status, 0);
   if (DBG_READER)
     {
       if (status)

commit 216afba0d99582d0fbae1d6e925f4ddb349d9de3
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Mon Jan 30 08:19:32 2017 +0900

    scd: Fix cancel INTERRUPT transfer.
    
    * scd/ccid-driver.c (do_close_reader): Don't lock events, but check the
    return value of libusb_cancel_transfer.
    
    Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>

diff --git a/scd/ccid-driver.c b/scd/ccid-driver.c
index bbdd697..305c9d2 100644
--- a/scd/ccid-driver.c
+++ b/scd/ccid-driver.c
@@ -2116,33 +2116,24 @@ do_close_reader (ccid_driver_t handle)
     {
       if (handle->transfer)
         {
-          /* By locking libusb events, make sure handle->transfer is
-             canceled properly;  Don't cancel completed transfer.  */
-#ifdef USE_NPTH
-          npth_unprotect ();
-#endif
-          libusb_lock_events (NULL);
-#ifdef USE_NPTH
-          npth_protect ();
-#endif
           if (!handle->powered_off)
             {
-              libusb_cancel_transfer (handle->transfer);
-              libusb_unlock_events (NULL);
+              DEBUGOUT ("libusb_cancel_transfer\n");
 
-              while (!handle->powered_off)
-                {
+              rc = libusb_cancel_transfer (handle->transfer);
+              if (rc != LIBUSB_ERROR_NOT_FOUND)
+                while (!handle->powered_off)
+                  {
+                    DEBUGOUT ("libusb_handle_events_completed\n");
 #ifdef USE_NPTH
-                  npth_unprotect ();
+                    npth_unprotect ();
 #endif
-                  libusb_handle_events_completed (NULL, &handle->powered_off);
+                    libusb_handle_events_completed (NULL, &handle->powered_off);
 #ifdef USE_NPTH
-                  npth_protect ();
+                    npth_protect ();
 #endif
-                }
+                  }
             }
-          else
-            libusb_unlock_events (NULL);
 
           libusb_free_transfer (handle->transfer);
         }

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

Summary of changes:
 scd/apdu.c        | 27 +++++++++++++++++++--------
 scd/ccid-driver.c | 29 ++++++++++-------------------
 2 files changed, 29 insertions(+), 27 deletions(-)


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




More information about the Gnupg-commits mailing list