Blob Blame History Raw
From a311075202865d22b87ec2ea8d1e32fa11868012 Mon Sep 17 00:00:00 2001
From: Bernhard Miklautz <bernhard.miklautz@thincast.com>
Date: Wed, 10 Jul 2019 18:36:34 +0200
Subject: [PATCH] fix [channels/smartcard]: fix StatusW_Call

According to 2.2.2.18 Status_Call cbAtrLen is unused an must be ignored
upon receipt.
---
 channels/smartcard/client/smartcard_operations.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/channels/smartcard/client/smartcard_operations.c b/channels/smartcard/client/smartcard_operations.c
index c4bf65d38..e3d848171 100644
--- a/channels/smartcard/client/smartcard_operations.c
+++ b/channels/smartcard/client/smartcard_operations.c
@@ -1209,15 +1209,19 @@ static LONG smartcard_StatusW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
 	Status_Call* call = operation->call;
 	DWORD cbAtrLen;
 
-	if (call->cbAtrLen > 32)
-		call->cbAtrLen = 32;
+	/**
+	 * [MS-RDPESC]
+	 * According to 2.2.2.18 Status_Call cbAtrLen is unused an must be ignored upon receipt.
+	 */
+	cbAtrLen = call->cbAtrLen = 32;
+
+	call->cchReaderLen;
 
 	if (call->fmszReaderNamesIsNULL)
 		cchReaderLen = 0;
 	else
 		cchReaderLen = SCARD_AUTOALLOCATE;
 
-	cbAtrLen = call->cbAtrLen;
 	ZeroMemory(ret.pbAtr, 32);
 	status = ret.ReturnCode = SCardStatusW(operation->hCard,
 	                                       call->fmszReaderNamesIsNULL ? NULL : (LPWSTR) &mszReaderNames,
@@ -1236,8 +1240,7 @@ static LONG smartcard_StatusW_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERAT
 		ret.cBytes = cchReaderLen;
 #endif
 
-		if (call->cbAtrLen)
-			ret.cbAtrLen = cbAtrLen;
+		ret.cbAtrLen = cbAtrLen;
 	}
 
 	smartcard_trace_status_return(smartcard, &ret, TRUE);
-- 
2.26.0