mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
Fix smartcard segfault when no devices are present (#5364)
* Don't assume smartcard reader list is not empty. * Check status of retrieval of smartcard device list before trying to filter it * style fixes
This commit is contained in:
@@ -457,7 +457,7 @@ static DWORD filter_device_by_name_a(wLinkedList* list, LPSTR* mszReaders, DWORD
|
||||
{
|
||||
size_t rpos = 0, wpos = 0;
|
||||
|
||||
if (LinkedList_Count(list) < 1)
|
||||
if (*mszReaders == NULL || LinkedList_Count(list) < 1)
|
||||
return cchReaders;
|
||||
|
||||
do
|
||||
@@ -547,9 +547,6 @@ static LONG smartcard_ListReadersA_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_O
|
||||
cchReaders = SCARD_AUTOALLOCATE;
|
||||
status = ret.ReturnCode = SCardListReadersA(operation->hContext, (LPCSTR) call->mszGroups,
|
||||
(LPSTR) &mszReaders, &cchReaders);
|
||||
cchReaders = filter_device_by_name_a(smartcard->names, &mszReaders, cchReaders);
|
||||
ret.msz = (BYTE*) mszReaders;
|
||||
ret.cBytes = cchReaders;
|
||||
|
||||
if (call->mszGroups)
|
||||
{
|
||||
@@ -563,6 +560,9 @@ static LONG smartcard_ListReadersA_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_O
|
||||
return status;
|
||||
}
|
||||
|
||||
cchReaders = filter_device_by_name_a(smartcard->names, &mszReaders, cchReaders);
|
||||
ret.msz = (BYTE*) mszReaders;
|
||||
ret.cBytes = cchReaders;
|
||||
smartcard_trace_list_readers_return(smartcard, &ret, FALSE);
|
||||
|
||||
if ((status = smartcard_pack_list_readers_return(smartcard, irp->output, &ret)))
|
||||
@@ -610,9 +610,6 @@ static LONG smartcard_ListReadersW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_O
|
||||
cchReaders = SCARD_AUTOALLOCATE;
|
||||
status = ret.ReturnCode = SCardListReadersW(operation->hContext,
|
||||
(LPCWSTR) call->mszGroups, (LPWSTR) &mszReaders, &cchReaders);
|
||||
cchReaders = filter_device_by_name_w(smartcard->names, &mszReaders, cchReaders);
|
||||
ret.msz = (BYTE*) mszReaders;
|
||||
ret.cBytes = cchReaders * 2;
|
||||
|
||||
if (call->mszGroups)
|
||||
{
|
||||
@@ -626,6 +623,9 @@ static LONG smartcard_ListReadersW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_O
|
||||
return status;
|
||||
}
|
||||
|
||||
cchReaders = filter_device_by_name_w(smartcard->names, &mszReaders, cchReaders);
|
||||
ret.msz = (BYTE*) mszReaders;
|
||||
ret.cBytes = cchReaders * 2;
|
||||
smartcard_trace_list_readers_return(smartcard, &ret, TRUE);
|
||||
|
||||
if ((status = smartcard_pack_list_readers_return(smartcard, irp->output, &ret)))
|
||||
|
||||
Reference in New Issue
Block a user