I am attaching the tested patch to the file ifd-ccid.c to add support for the reader. The reader's USB IDs that I tested with are 0b97:7762 and 0b97:7772. Without this patch the ifd-ccid.c code will not work with these readers.

The patch is based on the work done in the pcsc-lite project. The patch is made against openct-0.6.15-svn-r1127. I didn't make corresponding updates to text configuration files.

Thank you.
--- openct-0.6.15-svn-r1127/src/ifd/ifd-ccid.c  2009-01-29 13:03:01.000000000 
-0800
+++ openct-with-fix/src/ifd/ifd-ccid.c  2009-01-29 13:05:00.000000000 -0800
@@ -583,22 +583,50 @@
                                                    bEndpointAddress;
                                        }
                                }
                                if (ok == 7)
                                        break;
                                intf = NULL;
                        }
                        if (!intf)
                                continue;
                        if (!intf->extralen) {
-                               intf = NULL;
-                               continue;
+                               int i;
+                               /* Buggy O2 Micro CCID SC Reader has zero extra 
len at interface level but not endpoint descriptor.
+                                * Patch the interface level field and proceed.
+                                * ProdID 7762 reader is in Dell Latitude D620 
and 7772 is in D630.
+                                */
+                               if( de.idVendor == 0x0b97 && (de.idProduct == 
0x7762 || de.idProduct == 0x7772) )  {
+                                       ct_error("ccid: extra len is zero, 
patching O2 Micro support");
+                                       for (i=0; i<intf->bNumEndpoints; i++)  {
+                                               /* find the extra[] array */
+                                               if( intf->endpoint[i].extralen 
== 54 )  {
+                                                       /* get the extra[] from 
the endpoint */
+                                                       intf->extralen = 54;
+                                                       /* avoid double free on 
close, allocate here */
+                                                       intf->extra = 
malloc(54);
+                                                       if( intf->extra )  {
+                                                               memcpy( 
intf->extra, intf->endpoint[i].extra, 54 );
+                                                               break;
+                                                       }
+                                                       else  {
+                                                               intf = NULL;
+                                                               continue;
+                                                       }
+                                               }
+                                       }
+                               }
+                               else  {
+                                       intf = NULL;
+                                       ct_error("ccid: extra len is zero, 
continuing");
+                                       continue;
+                               }
                        }
 
                        r = intf->extralen;
                        _class = intf->extra;
                        i = 0;
                        p = _class + i;
                        /* 0x21 == USB_TYPE_CLASS | 0x1 */
                        /* accept descriptor type 0xFF if force_parse != 0 */
                        while (i < r && p[0] > 2 &&
                               (p[1] != 0x21 &&
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to