mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
Fixed issue with GetAttr where the result buffer was not allocated
This commit is contained in:
@@ -1813,23 +1813,24 @@ static LONG smartcard_GetAttrib_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPER
|
||||
if (!call->fpbAttrIsNULL)
|
||||
{
|
||||
autoAllocate = (call->cbAttrLen == SCARD_AUTOALLOCATE) ? TRUE : FALSE;
|
||||
pbAttr = autoAllocate ? (LPBYTE) & (ret.pbAttr) : ret.pbAttr;
|
||||
cbAttrLen = call->cbAttrLen;
|
||||
}
|
||||
if (cbAttrLen && !autoAllocate)
|
||||
{
|
||||
ret.pbAttr = (BYTE*)malloc(cbAttrLen);
|
||||
|
||||
if (cbAttrLen && !autoAllocate)
|
||||
{
|
||||
ret.pbAttr = (BYTE*)malloc(cbAttrLen);
|
||||
if (!ret.pbAttr)
|
||||
return SCARD_E_NO_MEMORY;
|
||||
}
|
||||
|
||||
if (!ret.pbAttr)
|
||||
return SCARD_E_NO_MEMORY;
|
||||
pbAttr = autoAllocate ? (LPBYTE) & (ret.pbAttr) : ret.pbAttr;
|
||||
}
|
||||
|
||||
ret.ReturnCode = SCardGetAttrib(operation->hCard, call->dwAttrId, pbAttr, &cbAttrLen);
|
||||
log_status_error(TAG, "SCardGetAttrib", ret.ReturnCode);
|
||||
ret.cbAttrLen = cbAttrLen;
|
||||
|
||||
status = smartcard_pack_get_attrib_return(smartcard, irp->output, &ret, call->dwAttrId);
|
||||
status = smartcard_pack_get_attrib_return(smartcard, irp->output, &ret, call->dwAttrId,
|
||||
call->cbAttrLen);
|
||||
|
||||
if (autoAllocate)
|
||||
SCardFreeMemory(operation->hContext, ret.pbAttr);
|
||||
|
||||
@@ -2791,7 +2791,8 @@ LONG smartcard_unpack_get_attrib_call(SMARTCARD_DEVICE* smartcard, wStream* s, G
|
||||
}
|
||||
|
||||
LONG smartcard_pack_get_attrib_return(SMARTCARD_DEVICE* smartcard, wStream* s,
|
||||
const GetAttrib_Return* ret, DWORD dwAttrId)
|
||||
const GetAttrib_Return* ret, DWORD dwAttrId,
|
||||
DWORD cbAttrCallLen)
|
||||
{
|
||||
LONG status;
|
||||
DWORD cbAttrLen;
|
||||
@@ -2802,10 +2803,12 @@ LONG smartcard_pack_get_attrib_return(SMARTCARD_DEVICE* smartcard, wStream* s,
|
||||
return SCARD_F_INTERNAL_ERROR;
|
||||
|
||||
cbAttrLen = ret->cbAttrLen;
|
||||
if (ret->ReturnCode == SCARD_E_INSUFFICIENT_BUFFER)
|
||||
if (ret->ReturnCode != SCARD_S_SUCCESS)
|
||||
cbAttrLen = 0;
|
||||
if (cbAttrLen == SCARD_AUTOALLOCATE)
|
||||
cbAttrLen = 0;
|
||||
if (cbAttrCallLen < cbAttrLen)
|
||||
cbAttrLen = cbAttrCallLen;
|
||||
Stream_Write_UINT32(s, cbAttrLen); /* cbAttrLen (4 bytes) */
|
||||
if (!smartcard_ndr_pointer_write(s, &index, cbAttrLen))
|
||||
return SCARD_E_NO_MEMORY;
|
||||
|
||||
@@ -140,7 +140,8 @@ LONG smartcard_unpack_get_attrib_call(SMARTCARD_DEVICE* smartcard, wStream* s,
|
||||
GetAttrib_Call* call);
|
||||
|
||||
LONG smartcard_pack_get_attrib_return(SMARTCARD_DEVICE* smartcard, wStream* s,
|
||||
const GetAttrib_Return* ret, DWORD dwAttrId);
|
||||
const GetAttrib_Return* ret, DWORD dwAttrId,
|
||||
DWORD cbAttrCallLen);
|
||||
|
||||
LONG smartcard_unpack_set_attrib_call(SMARTCARD_DEVICE* smartcard, wStream* s,
|
||||
SetAttrib_Call* call);
|
||||
|
||||
Reference in New Issue
Block a user