Hello all,
I have a very odd problem with pcsclite 1.2.0 that prevents SCARD_S_SUCCESS
from being returned by the SCardStatus function.
First, the background info:
Reader: OmniKey CardMan Desktop USB 2020
Drivers: cm2020_installer_v2_4_0_src.tar.gz (comes with bundled
pcsclite-1.2.0)
Kernel: 2.4.26
When I try running the "testpcsc" program in the src directory of pcsclite,
the SCardStatus command is unsuccessful. The result is insufficient buffer.
In the pcsc documentation (pcsc-lite-0.8.7.pdf), it says that "Insufficient
Buffer" means that the string length for reader name is not long enough. In
this case it returns the required string length in the 3rd parameter
(dwReaderLen in the case of testpcsc.c). However, the length is set to 50
before calling the function, and the function returns "Insufficient Buffer"
with a required length of 25! This does not make sense.
So I edited SCardStatus (in winscard.c) to read:
-------------------------------------------------
LONG SCardStatus(SCARDHANDLE hCard, LPSTR mszReaderNames, LPDWORD
pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD
pcbAtrLen)
{
return SCARD_S_SUCCESS;
}
-------------------------------------------------
I still get Insufficient Buffer with a required length of 25. If I edit the
above function to read "return SCARD_E_INVALID_PARAMETER", I get the correct
value back ("Invalid parameter"). The same is true for
"SCARD_E_INVALID_HANDLE", "SCARD_E_CANCELLED", etc. So every value is
returned correctly except SCARD_S_SUCCESS.
I do not understand how this is possible, as the value is checked
IMMEDIATELY after calling SCardStatus, nothing happens in between. This is
the relevant section of testpcsc.c:
-----------------------------------------------
...
if (rv == 0x80100008) //check if rv is already SCARD_E_INVALID_BUFFER
before SCardStatus is called
printf("TRUEBEFORE");
else
printf("NOTTRUEBEFORE");
//function is called here, and the only thing it does is "return
SCARD_S_SUCCESS"
rv = SCardStatus(hCard, pcReaders, &dwReaderLen, &dwState, &dwProt, pbAtr,
&dwAtrLen);
if (rv == 0x80100008) //check if rv is SCARD_E_INVALID_BUFFER after
function is called
{
printf("CONFIRMED");
printf(" requiredLen = %lu ",dwReaderLen);
}
printf("%s\n", pcsc_stringify_error(rv));
...
---------------------------------------------
So the output is something like:
---------------------------------------------
...
Reader 01: Omnikey CardMan 2020 0 0
Enter the reader number : 1
Waiting for card insertion
: Command
successful.
Testing SCardConnect : Command successful.
Testing SCardStatus : NOTTRUEBEFORECONFIRMED
requiredLen = 25 Insufficient buffer.
...
-------------------------------------------
So this means that the variable rv is *not* SCARD_E_INSUFFICIENT_BUFFER
before the function is called (NOTTRUEBEFORE), and yet it *is*
SCARD_E_INSUFFICIENT_BUFFER after the function is called (CONFIRMED
requiredLen = 25), and yet the only thing that the function does is "return
SCARD_S_SUCCESS;".
Does anyone know what is the issue here?
Regards,
Mladen
_______________________________________________
Muscle mailing list
[EMAIL PROTECTED]
http://lists.drizzle.com/mailman/listinfo/muscle