bugfix: case 2 extended length apdu are now recognized
git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@267 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
@@ -103,6 +103,14 @@ int build_apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu)
|
||||
if (*p == 0 && len > 2) {
|
||||
/* ...must be an extended length APDU */
|
||||
p++;
|
||||
if (len == 3) {
|
||||
apdu->le = (*p++)<<8;
|
||||
apdu->le += *p++;
|
||||
if (apdu->le == 0)
|
||||
apdu->le = 0xffff;
|
||||
len -= 3;
|
||||
apdu->cse = SC_APDU_CASE_2_SHORT;
|
||||
} else {
|
||||
apdu->lc = (*p++)<<8;
|
||||
apdu->lc += *p++;
|
||||
len -= 3;
|
||||
@@ -133,6 +141,7 @@ int build_apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu)
|
||||
(unsigned long) len);
|
||||
return SC_ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
apdu->lc = *p++;
|
||||
len--;
|
||||
@@ -172,7 +181,9 @@ int build_apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu)
|
||||
|
||||
apdu->flags = SC_APDU_FLAGS_NO_GET_RESP|SC_APDU_FLAGS_NO_RETRY_WL;
|
||||
|
||||
sc_debug(ctx, "APDU, %d bytes:\tins=%02x p1=%02x p2=%02x",
|
||||
sc_debug(ctx, "Case %d %s APDU, %u bytes:\tins=%02x p1=%02x p2=%02x",
|
||||
apdu->cse & SC_APDU_SHORT_MASK,
|
||||
(apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short",
|
||||
(unsigned int) len0, apdu->ins, apdu->p1, apdu->p2);
|
||||
|
||||
return SC_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user