[Pcsclite-git-commit] [CCID] 02/02: ZLP: enable the patch only if --enable-zlp is used

Ludovic Rousseau rousseau at moszumanska.debian.org
Wed Mar 22 17:37:31 UTC 2017


This is an automated email from the git hooks/post-receive script.

rousseau pushed a commit to branch master
in repository CCID.

commit 7e20d8d978d92194e05ab5e6dd51a2d3415f4487
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Tue Mar 21 18:26:51 2017 +0100

    ZLP: enable the patch only if --enable-zlp is used
    
    The Zero Length Packet patch has issues with some non-bogus readers. So
    the patch is _disabled_ by default.
    
    If your Gemalto reader suffer from the ZLP problem then recompile the CCID
    reader with:
    $ ./configure --enable-zlp
---
 configure.ac      | 9 +++++++++
 src/ccid.c        | 2 ++
 src/ccid.h        | 2 ++
 src/ccid_serial.c | 2 ++
 src/ccid_usb.c    | 4 ++++
 5 files changed, 19 insertions(+)

diff --git a/configure.ac b/configure.ac
index 688c207..4241674 100644
--- a/configure.ac
+++ b/configure.ac
@@ -265,6 +265,15 @@ if test x$use_embedded = xyes; then
   AC_DEFINE(NO_LOG, 1, [Disable logging support])
 fi
 
+# --enable-zlp
+AC_ARG_ENABLE(zlp,
+  AS_HELP_STRING([--enable-zlp],[enable the Zero Length Packet patch for some Gemalto readers]),
+  [ use_zlp="${enableval}" ])
+
+if test x$use_zlp = xyes; then
+  AC_DEFINE(ENABLE_ZLP, 1, [Enable Zero Length Packet patch])
+fi
+
 # Setup dist stuff
 AC_SUBST(ac_aux_dir)
 AC_SUBST(bundle)
diff --git a/src/ccid.c b/src/ccid.c
index 2fdbc71..3dc0456 100644
--- a/src/ccid.c
+++ b/src/ccid.c
@@ -67,6 +67,7 @@ int ccid_open_hack_pre(unsigned int reader_index)
 			ccid_descriptor->readTimeout = 60*1000; /* 60 seconds */
 			break;
 
+#ifdef ENABLE_ZLP
 		case GEMPCTWIN:
 		case GEMPCKEY:
 		case DELLSCRK:
@@ -79,6 +80,7 @@ int ccid_open_hack_pre(unsigned int reader_index)
 				DEBUG_INFO1("ZLP fixup");
 			}
 			break;
+#endif
 
 		case OZ776:
 		case OZ776_7772:
diff --git a/src/ccid.h b/src/ccid.h
index b09fe5f..fdc4a64 100644
--- a/src/ccid.h
+++ b/src/ccid.h
@@ -138,10 +138,12 @@ typedef struct
 	 */
 	struct GEMALTO_FIRMWARE_FEATURES *gemalto_firmware_features;
 
+#ifdef ENABLE_ZLP
 	/*
 	 * Zero Length Packet fixup (boolean)
 	 */
 	char zlp;
+#endif
 } _ccid_descriptor;
 
 /* Features from dwFeatures */
diff --git a/src/ccid_serial.c b/src/ccid_serial.c
index deffd07..1484c37 100644
--- a/src/ccid_serial.c
+++ b/src/ccid_serial.c
@@ -614,7 +614,9 @@ static status_t set_ccid_descriptor(unsigned int reader_index,
 	serialDevice[reader_index].ccid.dwSlotStatus = IFD_ICC_PRESENT;
 	serialDevice[reader_index].ccid.bVoltageSupport = 0x07;	/* 1.8V, 3V and 5V */
 	serialDevice[reader_index].ccid.gemalto_firmware_features = NULL;
+#ifdef ENABLE_ZLP
 	serialDevice[reader_index].ccid.zlp = FALSE;
+#endif
 	serialDevice[reader_index].echo = TRUE;
 
 	/* change some values depending on the reader */
diff --git a/src/ccid_usb.c b/src/ccid_usb.c
index 8c2ef77..1996cb8 100644
--- a/src/ccid_usb.c
+++ b/src/ccid_usb.c
@@ -722,7 +722,9 @@ again:
 				usbDevice[reader_index].ccid.bVoltageSupport = device_descriptor[5];
 				usbDevice[reader_index].ccid.sIFD_serial_number = NULL;
 				usbDevice[reader_index].ccid.gemalto_firmware_features = NULL;
+#ifdef ENABLE_ZLP
 				usbDevice[reader_index].ccid.zlp = FALSE;
+#endif
 				if (desc.iSerialNumber)
 				{
 					unsigned char serial[128];
@@ -822,6 +824,7 @@ status_t WriteUSB(unsigned int reader_index, unsigned int length,
 	(void)snprintf(debug_header, sizeof(debug_header), "-> %06X ",
 		(int)reader_index);
 
+#ifdef ENABLE_ZLP
 	if (usbDevice[reader_index].ccid.zlp)
 	{ /* Zero Length Packet */
 		int dummy_length;
@@ -831,6 +834,7 @@ status_t WriteUSB(unsigned int reader_index, unsigned int length,
 		(void)libusb_bulk_transfer(usbDevice[reader_index].dev_handle,
 			usbDevice[reader_index].bulk_in, NULL, 0, &dummy_length, 10);
 	}
+#endif
 
 	DEBUG_XXD(debug_header, buffer, length);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pcsclite/CCID.git



More information about the Pcsclite-cvs-commit mailing list