summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Andersson <hean01@cendio.com>2017-10-20 13:52:13 +0200
committerHenrik Andersson <hean01@cendio.com>2017-10-23 08:43:35 +0200
commit8c83f8957be91ab6cdc0c1fea1d716f9fc65945c (patch)
tree851c3074c3154559cf5e5f3cbc8e6e0665d739ba
parentaf08994cfdee643464ad73004a4953fe929c7f62 (diff)
downloadrdesktop-8c83f8957be91ab6cdc0c1fea1d716f9fc65945c.zip
Fix SCARD_AUTOALLOCATE handling
SCARD_AUTOALLOCATE is a define with value -1, which is compared to an uint32. There was some missassumtion of whenever its -1 or 0xffffffff through the code.
-rw-r--r--scard.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/scard.c b/scard.c
index 6695fd3..766eabf 100644
--- a/scard.c
+++ b/scard.c
@@ -2028,22 +2028,17 @@ TS_SCardGetAttrib(STREAM in, STREAM out)
"TS_SCardGetAttrib(), hcard: 0x%08x [0x%08lx], attrib: 0x%08x (%d bytes)",
(unsigned) hCard, (unsigned long) myHCard, (unsigned) dwAttrId, (int) dwAttrLen);
- if (dwAttrLen > MAX_BUFFER_SIZE)
+ pbAttr = NULL;
+ if (dwAttrLen != (SERVER_DWORD)SCARD_AUTOALLOCATE)
+ {
+ if (dwAttrLen > MAX_BUFFER_SIZE)
+ {
dwAttrLen = MAX_BUFFER_SIZE;
+ }
-
- if (dwAttrLen > SCARD_AUTOALLOCATE)
- pbAttr = NULL;
- else if ((dwAttrLen < 0) || (dwAttrLen > SCARD_MAX_MEM))
- {
- dwAttrLen = (SERVER_DWORD) SCARD_AUTOALLOCATE;
- pbAttr = NULL;
- }
- else
- {
- pbAttr = SC_xmalloc(&lcHandle, dwAttrLen);
- if (!pbAttr)
- return SC_returnNoMemoryError(&lcHandle, in, out);
+ pbAttr = SC_xmalloc(&lcHandle, dwAttrLen);
+ if (!pbAttr)
+ return SC_returnNoMemoryError(&lcHandle, in, out);
}
attrLen = dwAttrLen;