While trying to run OpenSC svn Revision: 4413 on Solaris 10 with
pcsc-lite 1.6.1, I was getting an error that the PCSC_TLV_STRUCTURE
was the wrong size. Using the Solaris /usr/sfw/bin/gcc 3.4.3
The reader is a GemPC Twin.

This problem comes down to the fact that OpenSC now has an
internal_reader.h that does not match the pcsc-lite reader.h
(reader.h.in) in a number of places.

On June 19, 2007 pcsc-lite reader.h.in was modified to treat the sun
like the APPLE when defining the #pragma pack commands. This change
was not in the opensc internal_reader.h

So on the sun, pcscd has sizeof(PCSC_TLV_STRUCTURE) = 6, (unaligned)
but opensc thinks sizeof(PCSC_TLV_STRUCTURE) = 8. (aligned)

In addition the PIN_PROPERTIES_STRUCTURE is different in both
having two extra  values in the OpenSC internal_reader.h

(ANy chance of going back to using the pcsc-lite version of
reader.h, at least on Unix?)

The cardctl.h has the same issue with #pragma pack(push, 1)
but will also fail on APPLE.

The svn version of reader-pcsc.c now does more feature checks
and this alignment and size differences now cause a failure.

There is also some missing code in reader-pcsc.c as it
sets display_ioctl for the FEATURE_IFD_PIN_PROPERTIES feature
then can not get the display propriety.

Attached are two diff files to fix these two issues in the three files.

--

 Douglas E. Engert  <deeng...@anl.gov>
 Argonne National Laboratory
 9700 South Cass Avenue
 Argonne, Illinois  60439
 (630) 252-5444
--- ,internal-winscard.h        Wed Jun 16 13:27:02 2010
+++ internal-winscard.h Wed Jun 16 14:29:33 2010
@@ -172,7 +172,7 @@
 
 /* Set structure elements aligment on bytes
  * http://gcc.gnu.org/onlinedocs/gcc/Structure_002dPacking-Pragmas.html */
-#ifdef __APPLE__
+#if defined(__APPLE__) | defined(sun)
 #pragma pack(1)
 #else
 #pragma pack(push, 1)
@@ -251,14 +251,12 @@
 
 typedef struct {
        uint16_t wLcdLayout; /**< display characteristics */
-       uint16_t wLcdMaxCharacters;
-       uint16_t wLcdMaxLines;
        uint8_t bEntryValidationCondition;
        uint8_t bTimeOut2;
 } PIN_PROPERTIES_STRUCTURE;
 
 /* restore default structure elements alignment */
-#ifdef __APPLE__
+#if defined(__APPLE__) | defined(sun)
 #pragma pack()
 #else
 #pragma pack(pop)
--- ,cardctl.h  Mon Jun 14 14:25:28 2010
+++ cardctl.h   Wed Jun 16 14:04:24 2010
@@ -556,7 +556,11 @@
 #define SC_RUTOKEN_DO_CHV_MAX_ID_V2       SC_RUTOKEN_DEF_ID_GCHV_USER  /*  MAX 
ID value of CHV-objects  */
 #define SC_RUTOKEN_DO_NOCHV_MAX_ID_V2     SC_RUTOKEN_DO_NOCHV_MAX_ID   /*  MAX 
ID value of All Other DOs  */
 
+#if defined(__APPLE__) || defined(sun)
+#pragma pack(1)
+#else
 #pragma pack(push, 1)
+#endif
 typedef u8 sc_SecAttrV2_t[40];
 
 typedef struct sc_ObjectTypeID{
@@ -671,7 +675,11 @@
        u8      *modulus;
 } sc_entersafe_gen_key_data;
 
+#if defined(__APPLE__) || defined(sun)
+#pragma pack()
+#else
 #pragma pack(pop)
+#endif
 
 /*
  * Rutoken ECP stuff
--- ,reader-pcsc.c      Mon Jun 14 14:25:28 2010
+++ reader-pcsc.c       Wed Jun 16 15:45:24 2010
@@ -873,6 +873,8 @@
                                                        } else if 
(pcsc_tlv[i].tag == FEATURE_MODIFY_PIN_FINISH) {
                                                                
priv->modify_ioctl_finish = ntohl(pcsc_tlv[i].value);
                                                        } else if 
(pcsc_tlv[i].tag == FEATURE_IFD_PIN_PROPERTIES) {
+                                                               ; /* some code 
missing here */
+                                                       } else if 
(pcsc_tlv[i].tag == FEATURE_IFD_DISPLAY_PROPERTIES) {
                                                                display_ioctl = 
ntohl(pcsc_tlv[i].value);
                                                        } else {
                                                                sc_debug(ctx, 
SC_LOG_DEBUG_NORMAL, "Reader feature %02x is not supported", pcsc_tlv[i].tag);
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to