Ticket #253: apdu.c.patch.3.txt

File apdu.c.patch.3.txt, 1.3 KB (added by dengert, 20 months ago)
Line 
1Index: apdu.c
2===================================================================
3--- apdu.c      (revision 4706)
4+++ apdu.c      (working copy)
5@@ -337,14 +337,13 @@
6 error:
7        sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid Case %d %s APDU:\n"
8                "cse=%02x cla=%02x ins=%02x p1=%02x p2=%02x lc=%lu le=%lu\n"
9-               "resp=%p resplen=%lu data=%p datalen=%lu max_send_size:%lu max_recv_size:%lu",
10+               "resp=%p resplen=%lu data=%p datalen=%lu",
11                apdu->cse & SC_APDU_SHORT_MASK,
12                (apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short",
13                apdu->cse, apdu->cla, apdu->ins, apdu->p1, apdu->p2,
14                (unsigned long) apdu->lc, (unsigned long) apdu->le,
15                apdu->resp, (unsigned long) apdu->resplen,
16-               apdu->data, (unsigned long) apdu->datalen,
17-               card->max_recv_size, card->max_send_size);
18+               apdu->data, (unsigned long) apdu->datalen);
19        return SC_ERROR_INVALID_ARGUMENTS;
20 }
21 
22@@ -487,12 +486,18 @@
23                                        SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);
24 
25                                if (buflen < le)
26-                                       return SC_ERROR_WRONG_LENGTH;
27+                               /* copy as much as will fit in requested buffer */
28+                                       le = buflen;
29 
30                                memcpy(buf, tbuf, le);
31                                buf    += le;
32                                buflen -= le;
33 
34+                               /* we have all the data the caller requested
35+                                * even if the card has more data */
36+                               if (buflen == 0)
37+                                       break;
38+
39                                minlen -= le;
40                                if (r != 0)
41                                        le = minlen = (size_t)r;