mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
Applied exact length hack.
This commit is contained in:
parent
cc25f43651
commit
c850656d28
@ -1,3 +1,8 @@
|
|||||||
|
2007-08-01 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* apdu.c (send_le): Implement exact length hack. Suggested by
|
||||||
|
Sten Lindgren.
|
||||||
|
|
||||||
2007-07-05 Werner Koch <wk@g10code.com>
|
2007-07-05 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* command.c (has_option_name, skip_options): New.
|
* command.c (has_option_name, skip_options): New.
|
||||||
|
13
scd/apdu.c
13
scd/apdu.c
@ -2609,7 +2609,8 @@ send_le (int slot, int class, int ins, int p0, int p1,
|
|||||||
unsigned char apdu[5+256+1];
|
unsigned char apdu[5+256+1];
|
||||||
size_t apdulen;
|
size_t apdulen;
|
||||||
int sw;
|
int sw;
|
||||||
long rc; /* we need a long here due to PC/SC. */
|
long rc; /* We need a long here due to PC/SC. */
|
||||||
|
int did_exact_length_hack = 0;
|
||||||
|
|
||||||
if (slot < 0 || slot >= MAX_READER || !reader_table[slot].used )
|
if (slot < 0 || slot >= MAX_READER || !reader_table[slot].used )
|
||||||
return SW_HOST_NO_DRIVER;
|
return SW_HOST_NO_DRIVER;
|
||||||
@ -2648,6 +2649,7 @@ send_le (int slot, int class, int ins, int p0, int p1,
|
|||||||
assert (sizeof (apdu) >= apdulen);
|
assert (sizeof (apdu) >= apdulen);
|
||||||
/* As safeguard don't pass any garbage from the stack to the driver. */
|
/* As safeguard don't pass any garbage from the stack to the driver. */
|
||||||
memset (apdu+apdulen, 0, sizeof (apdu) - apdulen);
|
memset (apdu+apdulen, 0, sizeof (apdu) - apdulen);
|
||||||
|
exact_length_hack:
|
||||||
resultlen = RESULTLEN;
|
resultlen = RESULTLEN;
|
||||||
rc = send_apdu (slot, apdu, apdulen, result, &resultlen, pininfo);
|
rc = send_apdu (slot, apdu, apdulen, result, &resultlen, pininfo);
|
||||||
if (rc || resultlen < 2)
|
if (rc || resultlen < 2)
|
||||||
@ -2658,7 +2660,14 @@ send_le (int slot, int class, int ins, int p0, int p1,
|
|||||||
return rc? rc : SW_HOST_INCOMPLETE_CARD_RESPONSE;
|
return rc? rc : SW_HOST_INCOMPLETE_CARD_RESPONSE;
|
||||||
}
|
}
|
||||||
sw = (result[resultlen-2] << 8) | result[resultlen-1];
|
sw = (result[resultlen-2] << 8) | result[resultlen-1];
|
||||||
/* store away the returned data but strip the statusword. */
|
if (!did_exact_length_hack && SW_EXACT_LENGTH_P (sw))
|
||||||
|
{
|
||||||
|
apdu[apdulen-1] = (sw & 0x00ff);
|
||||||
|
did_exact_length_hack = 1;
|
||||||
|
goto exact_length_hack;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Store away the returned data but strip the statusword. */
|
||||||
resultlen -= 2;
|
resultlen -= 2;
|
||||||
if (DBG_CARD_IO)
|
if (DBG_CARD_IO)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user