Re: Error with pcsc_scan - "buffer overflow detected"

Ludovic Rousseau <[email protected]>
Newsgroups gmane.comp.encryption.opensc.devel
Message-ID <CAGstE8DrXTZSyqNDtbY4ZsRzagUJe52hZHfJnwjBrK_FcK2pkg@mail.gmail.com>
Hello,

2016-07-27 22:54 GMT+02:00 Chris Green <[email protected]>:

> I'm trying to use openct and pcscd to read from a SIM card using a
> Phoenix based USB card reader.
>
> I'm running these on an xubuntu 14.04 system.  I'm using pcscd
> pcsc-tools and libpcsclite-dev from the Ubuntu repositories but I've
> been building my own openct as per your instructions:-
>
> https://github.com/OpenSC/openct/wiki/A-quick-installation-guide-to-openct
>
>
> I seem to have openct and openct-tool working OK:-
>
>     root@acer-aspire:~# openct-tool atr
>     Detected Phoenix reader
>     Card present, status changed
>     ATR: 3f 2f 00 80 69 af 03 07 03 5a 00 15 0a 0e 83 3e 9f 16 ff ff ff ff
> ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>

This ATR is far too long.


> However, should I be getting that string of 'ff ff ff ff ....' at the
> end?
>

No. It is a bug.


>
>
> Then if I run pcsc_scan I get:-
>
>     root@acer-aspire:/etc/reader.conf.d# pcsc_scan
>     PC/SC device scanner
>     V 1.4.22 (c) 2001-2011, Ludovic Rousseau <[email protected]>
>     Compiled with PC/SC lite version: 1.8.10
>     Using reader plug'n play mechanism
>     Scanning present readers...
>     0: openct 00 00
>     1: ��������������������
>
>     Wed Jul 27 21:37:22 2016
>     Reader 0: openct 00 00
>       Card state: Card inserted,
>       ATR: 3F 2F 00 80 69 AF 03 07 03 5A 00 15 0A 0E 83 3E 9F 16 FF FF FF
> FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 40 00 00 00 00 00 00 00 FF FF
> FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
>
>     *** buffer overflow detected ***: pcsc_scan terminated
>     ======= Backtrace: =========
>     /lib/i386-linux-gnu/libc.so.6(+0x68fce)[0xb75a9fce]
>     /lib/i386-linux-gnu/libc.so.6(__fortify_fail+0x6b)[0xb763cb8b]
>     /lib/i386-linux-gnu/libc.so.6(+0xfaa1a)[0xb763ba1a]
>     /lib/i386-linux-gnu/libc.so.6(+0xfa178)[0xb763b178]
>     /lib/i386-linux-gnu/libc.so.6(_IO_default_xsputn+0x8e)[0xb75b1d8e]
>     /lib/i386-linux-gnu/libc.so.6(_IO_vfprintf+0x4a79)[0xb7589289]
>     /lib/i386-linux-gnu/libc.so.6(__vsprintf_chk+0xb1)[0xb763b231]
>     /lib/i386-linux-gnu/libc.so.6(__sprintf_chk+0x2f)[0xb763b15f]
>     pcsc_scan[0x8048fc6]
>     /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb755aaf3]
>     pcsc_scan[0x80493ca]
>     ======= Memory map: ========
>     08048000-0804a000 r-xp 00000000 08:06 5642158    /usr/bin/pcsc_scan
>     0804a000-0804b000 r--p 00001000 08:06 5642158    /usr/bin/pcsc_scan
>     0804b000-0804c000 rw-p 00002000 08:06 5642158    /usr/bin/pcsc_scan
>     08393000-083b4000 rw-p 00000000 00:00 0          [heap]
>     b74f3000-b750f000 r-xp 00000000 08:06 5375119
> /lib/i386-linux-gnu/libgcc_s.so.1
>     b750f000-b7510000 rw-p 0001b000 08:06 5375119
> /lib/i386-linux-gnu/libgcc_s.so.1
>     b7523000-b7524000 rw-p 00000000 00:00 0
>     b7524000-b753c000 r-xp 00000000 08:06 5374047 /lib/i386-linux-gnu/
> libpthread-2.19.so
>     b753c000-b753d000 r--p 00018000 08:06 5374047 /lib/i386-linux-gnu/
> libpthread-2.19.so
>     b753d000-b753e000 rw-p 00019000 08:06 5374047 /lib/i386-linux-gnu/
> libpthread-2.19.so
>     b753e000-b7541000 rw-p 00000000 00:00 0
>     b7541000-b76e9000 r-xp 00000000 08:06 5374055 /lib/i386-linux-gnu/
> libc-2.19.so
>     b76e9000-b76ea000 ---p 001a8000 08:06 5374055 /lib/i386-linux-gnu/
> libc-2.19.so
>     b76ea000-b76ec000 r--p 001a8000 08:06 5374055 /lib/i386-linux-gnu/
> libc-2.19.so
>     b76ec000-b76ed000 rw-p 001aa000 08:06 5374055 /lib/i386-linux-gnu/
> libc-2.19.so
>     b76ed000-b76f0000 rw-p 00000000 00:00 0
>     b76f0000-b76fa000 r-xp 00000000 08:06 5375197
> /lib/i386-linux-gnu/libpcsclite.so.1.0.0
>     b76fa000-b76fb000 r--p 00009000 08:06 5375197
> /lib/i386-linux-gnu/libpcsclite.so.1.0.0
>     b76fb000-b76fc000 rw-p 0000a000 08:06 5375197
> /lib/i386-linux-gnu/libpcsclite.so.1.0.0
>     b770d000-b7711000 rw-p 00000000 00:00 0
>     b7711000-b7713000 r--p 00000000 00:00 0          [vvar]
>     b7713000-b7715000 r-xp 00000000 00:00 0          [vdso]
>     b7715000-b7735000 r-xp 00000000 08:06 5374048 /lib/i386-linux-gnu/
> ld-2.19.so
>     b7735000-b7736000 r--p 0001f000 08:06 5374048 /lib/i386-linux-gnu/
> ld-2.19.so
>     b7736000-b7737000 rw-p 00020000 08:06 5374048 /lib/i386-linux-gnu/
> ld-2.19.so
>     bf840000-bf861000 rw-p 00000000 00:00 0          [stack]
>     Aborted (core dumped)
>     root@acer-aspire:/etc/reader.conf.d#
>
>
> It's *almost* working!
>
> Can anyone suggest what might be wrong and what I can do about it?
>

I suspect a bug in OpenCT.

I suggest to use a CCID supported reader instead.

Bye

[1] https://pcsclite.alioth.debian.org/ccid/supported.html

-- 
 Dr. Ludovic Rousseau

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

_______________________________________________
Opensc-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensc-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.