Last active
August 4, 2021 09:28
-
-
Save hardening/a470c1870e42c679f5d9e83a9ed62162 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/channels/smartcard/client/smartcard_operations.c b/channels/smartcard/client/smartcard_operations.c | |
index f13b6ca53..df20c9b5a 100644 | |
--- a/channels/smartcard/client/smartcard_operations.c | |
+++ b/channels/smartcard/client/smartcard_operations.c | |
@@ -718,6 +718,7 @@ static LONG smartcard_ListReadersW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_O | |
string.bp = call->mszGroups; | |
cchReaders = SCARD_AUTOALLOCATE; | |
+ ZeroMemory(&mszReaders, sizeof(mszReaders)); | |
status = ret.ReturnCode = | |
SCardListReadersW(operation->hContext, string.wz, (LPWSTR)&mszReaders.pw, &cchReaders); | |
@@ -728,7 +729,10 @@ static LONG smartcard_ListReadersW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_O | |
} | |
if (status != SCARD_S_SUCCESS) | |
- return log_status_error(TAG, "SCardListReadersW", status); | |
+ { | |
+ /*return*/ log_status_error(TAG, "SCardListReadersW", status); | |
+ cchReaders = 0; | |
+ } | |
cchReaders = filter_device_by_name_w(smartcard->names, &mszReaders.pw, cchReaders); | |
ret.msz = mszReaders.pb; | |
diff --git a/channels/smartcard/client/smartcard_pack.c b/channels/smartcard/client/smartcard_pack.c | |
index 94a7be631..0735788d9 100644 | |
--- a/channels/smartcard/client/smartcard_pack.c | |
+++ b/channels/smartcard/client/smartcard_pack.c | |
@@ -205,16 +205,16 @@ static BOOL smartcard_ndr_pointer_write(wStream* s, UINT32* index, DWORD length) | |
return TRUE; | |
} | |
-static LONG smartcard_ndr_write(wStream* s, const BYTE* data, UINT32 size, UINT32 elementSize, | |
+static LONG smartcard_ndr_write(wStream* s, const BYTE* data, UINT32 count, UINT32 elementSize, | |
ndr_ptr_t type) | |
{ | |
const UINT32 offset = 0; | |
- const UINT32 len = size; | |
- const UINT32 dataLen = size * elementSize; | |
+ const UINT32 len = count; | |
+ const UINT32 dataLen = count * elementSize; | |
size_t required; | |
- if (size == 0) | |
- return SCARD_S_SUCCESS; | |
+/* if (count == 0) | |
+ return SCARD_S_SUCCESS;*/ | |
switch (type) | |
{ | |
@@ -247,10 +247,15 @@ static LONG smartcard_ndr_write(wStream* s, const BYTE* data, UINT32 size, UINT3 | |
} | |
if (data) | |
+ { | |
Stream_Write(s, data, dataLen); | |
+ } | |
else | |
- Stream_Zero(s, dataLen); | |
- return smartcard_pack_write_size_align(NULL, s, len, 4); | |
+ { | |
+ if (dataLen) | |
+ Stream_Zero(s, dataLen); | |
+ } | |
+ return smartcard_pack_write_size_align(NULL, s, dataLen, 4); | |
} | |
static LONG smartcard_ndr_write_state(wStream* s, const ReaderState_Return* data, UINT32 size, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment