Le 21 février 2012 09:24, Godfrey Chung <[email protected]> a écrit : > Dear Ludovic
Hello, > On Mon, Feb 20, 2012 at 11:21 PM, Godfrey Chung > <[email protected]> wrote: >> Compared with acsccid-1.0.3 with ccid-1.4.5, I found that I didn't >> merge your changes for the ControlUSB function. Your function checked >> the return value from libusb_control_transfer(). The returned value >> may be very large and cause DEBUG_XXD to fail. I will do more tests >> tomorrow. > > I used APG8201 for testing and reviewed the code from acsccid-1.0.3, > ccid-1.4.5 and pcsc-lite-1.8.2. The problem is not related to libusb > or kernel. > > I found that the real problem is in DEBUG_XXD macro which calls > log_xxd from pcsc-lite. From my testing, I got error code "-84" from > usb_control_msg. Because acsccid is missing a check of error code in > ControlUSB, it passed the error code directly to DEBUG_XXD. Then, > pcscd is suddenly terminated with segmentation fault. > > In pcsc-lite, log_xxd calls log_xxd_always. log_xxd_always accepts > negative number in len parameter and use the value for the array size > of DebugBuffer. Fixed in pcsc-lite revision 6229. Thanks. http://lists.alioth.debian.org/pipermail/pcsclite-cvs-commit/2012-February/005780.html But the real problem is in your code calling a dump function with a negative length. I am not sure fixing pcsc-lite was a good idea after all. In my CCID driver the log is called _only_ if libusb_control_transfer() succeeds. This has been fixed in September 2011 in revision 5959. http://lists.alioth.debian.org/pipermail/pcsclite-cvs-commit/2011-September/005510.html > Suggested code change for ccid-1.4.5 (src/ccid_usb.c): > > Use of STATUS_UNSUCCESSFUL as return code is not appropriate. > STATUS_UNSUCCESSFUL is a positive number. > > int ControlUSB(int reader_index, int requesttype, int request, int value, > unsigned char *bytes, unsigned int size) > { > int ret; > > DEBUG_COMM2("request: 0x%02X", request); > > if (0 == (requesttype & 0x80)) > DEBUG_XXD("send: ", bytes, size); > > ret = libusb_control_transfer(usbDevice[reader_index].dev_handle, > requesttype, request, value, usbDevice[reader_index].interface, > bytes, size, usbDevice[reader_index].ccid.readTimeout); > > if (ret < 0) > { > DEBUG_CRITICAL5("control failed (%d/%d): %d %s", > usbDevice[reader_index].bus_number, > usbDevice[reader_index].device_address, ret, > strerror(errno)); > > return ret; // STATUS_UNSUCCESSFUL; > } > > if (requesttype & 0x80) > DEBUG_XXD("receive: ", bytes, ret); > > return ret; > } /* ControlUSB */ I can't do that. In fact I did but reverted the change in revision 6096 http://lists.alioth.debian.org/pipermail/pcsclite-cvs-commit/2011-November/005647.html I understand why you do not want to upgrade your CCID driver and do not resync with the current version of my CCID driver. The cost is that bugs I fix are not fixed in your driver. Bye -- Dr. Ludovic Rousseau _______________________________________________ Muscle mailing list [email protected] http://lists.drizzle.com/mailman/listinfo/muscle
