Error with pcsc_scan - "buffer overflow detected"

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Error with pcsc_scan - "buffer overflow detected"

Chris Green
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

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


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 <[hidden email]>
    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?

--
Chris Green

------------------------------------------------------------------------------
_______________________________________________
Opensc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Error with pcsc_scan - "buffer overflow detected"

Ludovic Rousseau
Hello,

2016-07-27 22:54 GMT+02:00 Chris Green <[hidden email]>:
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 <[hidden email]>
    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
--
 Dr. Ludovic Rousseau

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

_______________________________________________
Opensc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Error with pcsc_scan - "buffer overflow detected"

Chris Green
On Sat, Jul 30, 2016 at 11:26:41PM +0200, Ludovic Rousseau wrote:
[snip openct problem]
>
>    I suspect a bug in OpenCT.
>    I suggest to use a CCID supported reader instead.

Are there such readers which can read a SIM card?

--
Chris Green

------------------------------------------------------------------------------
_______________________________________________
Opensc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Error with pcsc_scan - "buffer overflow detected"

Ludovic Rousseau
2016-07-31 10:54 GMT+02:00 Chris Green <[hidden email]>:
On Sat, Jul 30, 2016 at 11:26:41PM +0200, Ludovic Rousseau wrote:
[snip openct problem]
>
>    I suspect a bug in OpenCT.
>    I suggest to use a CCID supported reader instead.

Are there such readers which can read a SIM card?

By SIM card I guess you mean the mini SIM, or 2FF, smart card format [1].
Yes, such readers exists. Like the Gemalto IDBridge K30 [2] and some others.

Bye
[2] https://pcsclite.alioth.debian.org/ccid/shouldwork.html#0x08E60x3438

--
 Dr. Ludovic Rousseau

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

_______________________________________________
Opensc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Error with pcsc_scan - "buffer overflow detected"

Chris Green
On Sun, Jul 31, 2016 at 04:01:00PM +0200, Ludovic Rousseau wrote:

>    2016-07-31 10:54 GMT+02:00 Chris Green <[1][hidden email]>:
>
>      On Sat, Jul 30, 2016 at 11:26:41PM +0200, Ludovic Rousseau wrote:
>      [snip openct problem]
>      >
>      >    I suspect a bug in OpenCT.
>      >    I suggest to use a CCID supported reader instead.
>      Are there such readers which can read a SIM card?
>
>    By SIM card I guess you mean the mini SIM, or 2FF, smart card format
>    [1].

Yes, that's the one.

>    Yes, such readers exists. Like the Gemalto IDBridge K30 [2] and some
>    others.

Thank you, they're not too expensive either, £12.95, so I'll get one
and should be able to progress from there.


--
Chris Green

------------------------------------------------------------------------------
_______________________________________________
Opensc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opensc-devel