Fix #257 Reading partial objects differs for T=0 vs T=1

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4761 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
dengert 2010-09-22 14:55:03 +00:00
parent 573a1de4d6
commit 10a5d1be3a
1 changed files with 10 additions and 1 deletions

View File

@ -473,7 +473,11 @@ static int do_single_transmit(sc_card_t *card, sc_apdu_t *apdu)
/* 0x6100 means at least 256 more bytes to read */
le = apdu->sw2 != 0 ? (size_t)apdu->sw2 : 256;
/* we try to read at least as much as bytes as
* promised in the response bytes */
* promised in the response bytes, but not more then
* then requested. So now T=0 responds the same as T=1
*/
if (buflen < le)
le = buflen;
minlen = le;
do {
@ -492,6 +496,11 @@ static int do_single_transmit(sc_card_t *card, sc_apdu_t *apdu)
buf += le;
buflen -= le;
/* we have all the data the caller requested
* even if the card has more data */
if (buflen == 0)
break;
minlen -= le;
if (r != 0)
le = minlen = (size_t)r;