From fab649a1b9396ba37ae877ca8f1165754d407689 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Fri, 19 Mar 2021 16:57:59 +0100 Subject: [PATCH] Fixed return length check for SCardGetAttrib --- channels/smartcard/client/smartcard_pack.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/channels/smartcard/client/smartcard_pack.c b/channels/smartcard/client/smartcard_pack.c index d22ad74ab..68c983f85 100644 --- a/channels/smartcard/client/smartcard_pack.c +++ b/channels/smartcard/client/smartcard_pack.c @@ -2822,8 +2822,12 @@ LONG smartcard_pack_get_attrib_return(SMARTCARD_DEVICE* smartcard, wStream* s, cbAttrLen = 0; if (cbAttrLen == SCARD_AUTOALLOCATE) cbAttrLen = 0; - if (cbAttrCallLen < cbAttrLen) - cbAttrLen = cbAttrCallLen; + + if (ret->pbAttr) + { + if (cbAttrCallLen < cbAttrLen) + cbAttrLen = cbAttrCallLen; + } Stream_Write_UINT32(s, cbAttrLen); /* cbAttrLen (4 bytes) */ if (!smartcard_ndr_pointer_write(s, &index, cbAttrLen)) return SCARD_E_NO_MEMORY;