SCardListReadersW return length is in bytes, not char.
authorArmin Novak <armin.novak@thincast.com>
Thu, 20 Feb 2020 14:21:17 +0000 (15:21 +0100)
committerArmin Novak <armin.novak@thincast.com>
Thu, 20 Feb 2020 14:24:03 +0000 (15:24 +0100)
channels/smartcard/client/smartcard_operations.c
channels/smartcard/client/smartcard_pack.c

index 6c009e4..444c668 100644 (file)
@@ -716,7 +716,6 @@ static LONG smartcard_ListReadersW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_O
        cchReaders = filter_device_by_name_w(smartcard->names, &mszReaders.pw, cchReaders);
        ret.msz = mszReaders.pb;
        ret.cBytes = cchReaders;
-
        status = smartcard_pack_list_readers_return(smartcard, irp->output, &ret, TRUE);
 
        if (mszReaders.pb)
index b70d030..2faf8c3 100644 (file)
@@ -2079,6 +2079,9 @@ LONG smartcard_pack_list_readers_return(SMARTCARD_DEVICE* smartcard, wStream* s,
                                         const ListReaders_Return* ret, BOOL unicode)
 {
        DWORD index = 0;
+       UINT32 size = unicode ? sizeof(WCHAR) : sizeof(CHAR);
+
+       size *= ret->cBytes;
 
        smartcard_trace_list_readers_return(smartcard, ret, unicode);
        if (ret->ReturnCode != SCARD_S_SUCCESS)
@@ -2090,12 +2093,11 @@ LONG smartcard_pack_list_readers_return(SMARTCARD_DEVICE* smartcard, wStream* s,
                return SCARD_F_INTERNAL_ERROR;
        }
 
-       Stream_Write_UINT32(s, ret->cBytes); /* cBytes (4 bytes) */
-       if (!smartcard_ndr_pointer_write(s, &index, ret->cBytes))
+       Stream_Write_UINT32(s, size); /* cBytes (4 bytes) */
+       if (!smartcard_ndr_pointer_write(s, &index, size))
                return SCARD_E_NO_MEMORY;
 
-       return smartcard_ndr_write(s, ret->msz, ret->cBytes, unicode ? sizeof(WCHAR) : sizeof(CHAR),
-                                  NDR_PTR_SIMPLE);
+       return smartcard_ndr_write(s, ret->msz, size, 1, NDR_PTR_SIMPLE);
 }
 
 static LONG smartcard_unpack_connect_common(SMARTCARD_DEVICE* smartcard, wStream* s,