channels/smartcard: fix SCardTransmit return encoding with pioRecvPci

This commit is contained in:
Marc-André Moreau 2015-02-20 15:39:51 -05:00
parent ebdcf041f9
commit bc50c81a0a
2 changed files with 12 additions and 11 deletions

View File

@ -913,8 +913,10 @@ static UINT32 smartcard_Transmit_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPE
}
ret.pioRecvPci = call->pioRecvPci;
status = ret.ReturnCode = SCardTransmit(operation->hCard, call->pioSendPci, call->pbSendBuffer,
call->cbSendLength, ret.pioRecvPci, ret.pbRecvBuffer, &(ret.cbRecvLength));
smartcard_trace_transmit_return(smartcard, &ret);
status = smartcard_pack_transmit_return(smartcard, irp->output, &ret);

View File

@ -2091,13 +2091,6 @@ UINT32 smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, T
Stream_Read_UINT32(s, call->fpbRecvBufferIsNULL); /* fpbRecvBufferIsNULL (4 bytes) */
Stream_Read_UINT32(s, call->cbRecvLength); /* cbRecvLength (4 bytes) */
if (pioRecvPciNdrPtr)
{
WLog_DBG(TAG, "Transmit_Call with pioRecvPci:");
winpr_HexDump(TAG, WLOG_WARN, Stream_Pointer(s) - 32,
Stream_GetRemainingLength(s) + 32);
}
if (ioSendPci.cbExtraBytes > 1024)
{
WLog_WARN(TAG, "Transmit_Call ioSendPci.cbExtraBytes is out of bounds: %d (max: %d)",
@ -2405,12 +2398,13 @@ UINT32 smartcard_pack_transmit_return(SMARTCARD_DEVICE* smartcard, wStream* s, T
BYTE* pbExtraBytes;
UINT32 pioRecvPciNdrPtr;
UINT32 pbRecvBufferNdrPtr;
UINT32 pbExtraBytesNdrPtr;
if (!ret->pbRecvBuffer)
ret->cbRecvLength = 0;
pioRecvPciNdrPtr = (ret->pioRecvPci) ? 0x00020200 : 0;
pbRecvBufferNdrPtr = (ret->pbRecvBuffer) ? 0x00020400 : 0;
pioRecvPciNdrPtr = (ret->pioRecvPci) ? 0x00020000 : 0;
pbRecvBufferNdrPtr = (ret->pbRecvBuffer) ? 0x00020004 : 0;
Stream_Write_UINT32(s, pioRecvPciNdrPtr); /* pioRecvPciNdrPtr (4 bytes) */
Stream_Write_UINT32(s, ret->cbRecvLength); /* cbRecvLength (4 bytes) */
@ -2420,12 +2414,17 @@ UINT32 smartcard_pack_transmit_return(SMARTCARD_DEVICE* smartcard, wStream* s, T
{
cbExtraBytes = ret->pioRecvPci->cbPciLength - sizeof(SCARD_IO_REQUEST);
pbExtraBytes = &((BYTE*) ret->pioRecvPci)[sizeof(SCARD_IO_REQUEST)];
pbExtraBytesNdrPtr = cbExtraBytes ? 0x00020008 : 0;
Stream_EnsureRemainingCapacity(s, cbExtraBytes + 16);
Stream_Write_UINT32(s, cbExtraBytes); /* Length (4 bytes) */
Stream_Write_UINT32(s, ret->pioRecvPci->dwProtocol); /* dwProtocol (4 bytes) */
Stream_Write_UINT32(s, cbExtraBytes); /* cbExtraBytes (4 bytes) */
Stream_Write(s, pbExtraBytes, cbExtraBytes);
Stream_Write_UINT32(s, pbExtraBytesNdrPtr); /* pbExtraBytesNdrPtr (4 bytes) */
if (pbExtraBytesNdrPtr)
Stream_Write(s, pbExtraBytes, cbExtraBytes);
smartcard_pack_write_size_align(smartcard, s, cbExtraBytes, 4);
}