[Pcsclite-cvs-commit] r3020 - /trunk/PCSC/src/winscard_clnt.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Tue Jun 24 09:58:34 UTC 2008
Author: rousseau
Date: Tue Jun 24 09:58:34 2008
New Revision: 3020
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=3020
Log:
SCardGetAttrib(): add support of SCARD_AUTOALLOCATE
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=3020&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_clnt.c (original)
+++ trunk/PCSC/src/winscard_clnt.c Tue Jun 24 09:58:34 2008
@@ -2577,18 +2577,33 @@
LPDWORD pcbAttrLen)
{
LONG ret;
+ unsigned char *buf = NULL;
PROFILE_START
if (NULL == pcbAttrLen)
return SCARD_E_INVALID_PARAMETER;
- /* if only get the length */
- if (NULL == pbAttr)
- /* this variable may not be set by the caller. use a reasonable size */
+ if (SCARD_AUTOALLOCATE == *pcbAttrLen)
+ {
*pcbAttrLen = MAX_BUFFER_SIZE;
-
- ret = SCardGetSetAttrib(hCard, SCARD_GET_ATTRIB, dwAttrId, pbAttr,
+ buf = malloc(*pcbAttrLen);
+ if (NULL == buf)
+ return SCARD_E_NO_MEMORY;
+
+ *(unsigned char **)pbAttr = buf;
+ }
+ else
+ {
+ buf = pbAttr;
+
+ /* if only get the length */
+ if (NULL == pbAttr)
+ /* use a reasonable size */
+ *pcbAttrLen = MAX_BUFFER_SIZE;
+ }
+
+ ret = SCardGetSetAttrib(hCard, SCARD_GET_ATTRIB, dwAttrId, buf,
pcbAttrLen);
PROFILE_END(ret)
More information about the Pcsclite-cvs-commit
mailing list