[Pcsclite-cvs-commit] r3068 - /trunk/PCSC/src/winscard_clnt.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Wed Jul 30 14:02:33 UTC 2008
Author: rousseau
Date: Wed Jul 30 14:02:32 2008
New Revision: 3068
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=3068
Log:
SCardStatus(): add support of SCARD_AUTOALLOCATE for pcchReaderLen and
pcbAtrLen
Modified:
trunk/PCSC/src/winscard_clnt.c
Modified: trunk/PCSC/src/winscard_clnt.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_clnt.c?rev=3068&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_clnt.c (original)
+++ trunk/PCSC/src/winscard_clnt.c Wed Jul 30 14:02:32 2008
@@ -1502,6 +1502,8 @@
sharedSegmentMsg msgStruct;
DWORD dwContextIndex, dwChannelIndex;
char *r;
+ char *bufReader = NULL;
+ LPBYTE bufAtr = NULL;
PROFILE_START
@@ -1613,26 +1615,54 @@
if (pdwProtocol)
*pdwProtocol = (readerStates[i])->cardProtocol;
+ if (SCARD_AUTOALLOCATE == dwReaderLen)
+ {
+ dwReaderLen = *pcchReaderLen;
+ bufReader = malloc(dwReaderLen);
+ if (NULL == bufReader)
+ {
+ rv = SCARD_E_NO_MEMORY;
+ goto end;
+ }
+ *(char **)mszReaderNames = bufReader;
+ }
+ else
+ bufReader = mszReaderNames;
+
/* return SCARD_E_INSUFFICIENT_BUFFER only if buffer pointer is non NULL */
- if (mszReaderNames)
+ if (bufReader)
{
if (*pcchReaderLen > dwReaderLen)
rv = SCARD_E_INSUFFICIENT_BUFFER;
- strncpy(mszReaderNames,
+ strncpy(bufReader,
psContextMap[dwContextIndex].psChannelMap[dwChannelIndex].readerName,
dwReaderLen);
}
- if (pbAtr)
+ if (SCARD_AUTOALLOCATE == dwAtrLen)
+ {
+ dwAtrLen = *pcbAtrLen;
+ bufAtr = malloc(dwAtrLen);
+ if (NULL == bufAtr)
+ {
+ rv = SCARD_E_NO_MEMORY;
+ goto end;
+ }
+ *(LPBYTE *)pbAtr = bufAtr;
+ }
+ else
+ bufAtr = pbAtr;
+
+ if (bufAtr)
{
if (*pcbAtrLen > dwAtrLen)
rv = SCARD_E_INSUFFICIENT_BUFFER;
- memcpy(pbAtr, (readerStates[i])->cardAtr,
- min(*pcbAtrLen, dwAtrLen));
- }
-
+ memcpy(bufAtr, (readerStates[i])->cardAtr, min(*pcbAtrLen, dwAtrLen));
+ }
+
+end:
SYS_MutexUnLock(psContextMap[dwContextIndex].mMutex);
PROFILE_END(rv)
More information about the Pcsclite-cvs-commit
mailing list