From 7ea4681b9548a4166809ee745814ae944f1c56a2 Mon Sep 17 00:00:00 2001 From: Tomaz Solc Date: Wed, 21 Feb 2018 20:38:18 +0100 Subject: [PATCH] Revert "SCardTransmit() may return SCARD_E_INSUFFICIENT_BUFFER" This reverts commit 8eb9ea1b354b050f997d003cf3b0c5b56f29f9f7. --- src/winscard_clnt.c | 2 +- src/winscard_svc.c | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/winscard_clnt.c b/src/winscard_clnt.c index d822418..ac9739c 100644 --- a/src/winscard_clnt.c +++ b/src/winscard_clnt.c @@ -2625,7 +2625,7 @@ end: * * @return Error code. * @retval SCARD_S_SUCCESS Successful (\ref SCARD_S_SUCCESS) - * @retval SCARD_E_INSUFFICIENT_BUFFER \p cbRecvLength was not large enough for the card response. The expected size is now in \p cbRecvLength (\ref SCARD_E_INSUFFICIENT_BUFFER) + * @retval SCARD_E_INSUFFICIENT_BUFFER \p cbSendLength or \p cbRecvLength are too big (\ref SCARD_E_INSUFFICIENT_BUFFER) * @retval SCARD_E_INVALID_HANDLE Invalid \p hCard handle (\ref SCARD_E_INVALID_HANDLE) * @retval SCARD_E_INVALID_PARAMETER \p pbSendBuffer or \p pbRecvBuffer or \p pcbRecvLength or \p pioSendPci is null (\ref SCARD_E_INVALID_PARAMETER) * @retval SCARD_E_INVALID_VALUE Invalid Protocol, reader name, etc (\ref SCARD_E_INVALID_VALUE) diff --git a/src/winscard_svc.c b/src/winscard_svc.c index d6b3c7b..57aba2e 100644 --- a/src/winscard_svc.c +++ b/src/winscard_svc.c @@ -661,18 +661,12 @@ static void ContextThread(LPVOID newContext) ioSendPci.cbPciLength = trStr.ioSendPciLength; ioRecvPci.dwProtocol = trStr.ioRecvPciProtocol; ioRecvPci.cbPciLength = trStr.ioRecvPciLength; - cbRecvLength = sizeof pbRecvBuffer; + cbRecvLength = trStr.pcbRecvLength; trStr.rv = SCardTransmit(trStr.hCard, &ioSendPci, pbSendBuffer, trStr.cbSendLength, &ioRecvPci, pbRecvBuffer, &cbRecvLength); - if (cbRecvLength > trStr.pcbRecvLength) - /* The client buffer is not large enough. - * The pbRecvBuffer buffer will NOT be sent a few - * lines bellow. So no buffer overflow is expected. */ - trStr.rv = SCARD_E_INSUFFICIENT_BUFFER; - trStr.ioSendPciProtocol = ioSendPci.dwProtocol; trStr.ioSendPciLength = ioSendPci.cbPciLength; trStr.ioRecvPciProtocol = ioRecvPci.dwProtocol; -- 2.11.0