Package: libcacard / 1:2.5.0-3

dont-fail-if-caller-didn-t-pick-previous-response.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From: Jakub Jelen <jjelen@redhat.com>
Date: Fri, 12 Aug 2016 11:31:37 +0200
Subject: Do not fail, if the caller didn't pick up response from previous call
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Commit-Id: ad591057c301d3120c3f7e5a5826342c8bf523bc

During our testing of a new CAC driver in OpenSC, with this library, we
encountered a problem with |libcacard| failing and the driver returning
only a fraction of the requested objects.

The problem is that the Emulator wants to return the data (properly
signalized by 61 (RESPONSE BYTES) in SW1), but this is ignored for some
reason in some of our calls from OpenSC. The Emulator should not fail
hard for the next independent request, rather silently drop the buffer
and serve the ongoing APDU request (I would left for consideration to
somehow log such problem).

Patch was successfully tested on Fedora 24 host and solves our problem
(though we worked around the problem already in the driver too).

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 src/card_7816.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/card_7816.c b/src/card_7816.c
index 8b12689..b598ef9 100644
--- a/src/card_7816.c
+++ b/src/card_7816.c
@@ -732,11 +732,9 @@ vcard_process_apdu(VCard *card, VCardAPDU *apdu, VCardResponse **response)
     }
     buffer_response = vcard_get_buffer_response(card);
     if (buffer_response && apdu->a_ins != VCARD7816_INS_GET_RESPONSE) {
-        /* clear out buffer_response, return an error */
+        /* clear out buffer_response, do not return an error */
         vcard_set_buffer_response(card, NULL);
         vcard_buffer_response_delete(buffer_response);
-        *response = vcard_make_response(VCARD7816_STATUS_EXC_ERROR);
-        return VCARD_DONE;
     }
 
     status = vcard_process_applet_apdu(card, apdu, response);
-- 
2.1.4