mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
Fixed 8bit and 16bit return string sizes.
This commit is contained in:
@@ -712,7 +712,7 @@ static LONG smartcard_ListReadersW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_O
|
||||
|
||||
cchReaders = filter_device_by_name_w(smartcard->names, &mszReaders, cchReaders);
|
||||
ret.msz = (BYTE*)mszReaders;
|
||||
ret.cBytes = cchReaders * 2;
|
||||
ret.cBytes = cchReaders;
|
||||
|
||||
status = smartcard_pack_list_readers_return(smartcard, irp->output, &ret, TRUE);
|
||||
|
||||
@@ -1613,7 +1613,6 @@ static LONG smartcard_StatusW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
|
||||
{
|
||||
LONG status;
|
||||
Status_Return ret = { 0 };
|
||||
DWORD cchReaderLen = 0;
|
||||
LPWSTR mszReaderNames = NULL;
|
||||
IRP* irp = operation->irp;
|
||||
Status_Call* call = operation->call;
|
||||
@@ -1626,28 +1625,20 @@ static LONG smartcard_StatusW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
|
||||
cbAtrLen = call->cbAtrLen = 32;
|
||||
|
||||
if (call->fmszReaderNamesIsNULL)
|
||||
cchReaderLen = 0;
|
||||
ret.cBytes = 0;
|
||||
else
|
||||
cchReaderLen = SCARD_AUTOALLOCATE;
|
||||
ret.cBytes = SCARD_AUTOALLOCATE;
|
||||
|
||||
ZeroMemory(ret.pbAtr, 32);
|
||||
status = ret.ReturnCode =
|
||||
SCardStatusW(operation->hCard, call->fmszReaderNamesIsNULL ? NULL : (LPWSTR)&mszReaderNames,
|
||||
&cchReaderLen, &ret.dwState, &ret.dwProtocol, (BYTE*)&ret.pbAtr, &cbAtrLen);
|
||||
&ret.cBytes, &ret.dwState, &ret.dwProtocol, (BYTE*)&ret.pbAtr, &cbAtrLen);
|
||||
log_status_error(TAG, "SCardStatusW", status);
|
||||
if (status == SCARD_S_SUCCESS)
|
||||
{
|
||||
if (!call->fmszReaderNamesIsNULL)
|
||||
ret.mszReaderNames = (BYTE*)mszReaderNames;
|
||||
|
||||
// WinScard returns the number of CHARACTERS whereas pcsc-lite returns the
|
||||
// number of BYTES.
|
||||
#ifdef _WIN32
|
||||
ret.cBytes = cchReaderLen * 2;
|
||||
#else
|
||||
ret.cBytes = cchReaderLen;
|
||||
#endif
|
||||
|
||||
ret.cbAtrLen = cbAtrLen;
|
||||
}
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ static LONG smartcard_ndr_write(wStream* s, const BYTE* data, UINT32 size, UINT3
|
||||
break;
|
||||
}
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(s, required + dataLen))
|
||||
if (!Stream_EnsureRemainingCapacity(s, required + dataLen + 4))
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
|
||||
switch (type)
|
||||
@@ -247,9 +247,7 @@ static LONG smartcard_ndr_write(wStream* s, const BYTE* data, UINT32 size, UINT3
|
||||
Stream_Write(s, data, dataLen);
|
||||
else
|
||||
Stream_Zero(s, dataLen);
|
||||
smartcard_pack_write_size_align(NULL, s, len, 4);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
return smartcard_pack_write_size_align(NULL, s, len, 4);
|
||||
}
|
||||
|
||||
static LONG smartcard_ndr_write_state(wStream* s, const ReaderState_Return* data, UINT32 size,
|
||||
|
||||
@@ -1850,12 +1850,7 @@ static LONG WINAPI PCSC_SCardStatus_Internal(SCARDHANDLE hCard, LPSTR mszReaderN
|
||||
*pcbAtrLen = (DWORD)pcsc_cbAtrLen;
|
||||
|
||||
if (pcchReaderLen)
|
||||
{
|
||||
if (unicode)
|
||||
*pcchReaderLen = (pcsc_cchReaderLen + 1) * 2;
|
||||
else
|
||||
*pcchReaderLen = pcsc_cchReaderLen + 1;
|
||||
}
|
||||
*pcchReaderLen = pcsc_cchReaderLen + 1;
|
||||
|
||||
/* Make sure the last byte is set */
|
||||
if (readerNames)
|
||||
|
||||
Reference in New Issue
Block a user