mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
scd: Handle error correctly.
* scd/apdu.c (apdu_connect): Initialize variables and check an error of apdu_get_status_internal. -- Backport from master commit: 6bb7206e357acfd7276a8f1334c0f0c9cc6ed100
This commit is contained in:
parent
a6f7c8d9b7
commit
af7245e9a7
10
scd/apdu.c
10
scd/apdu.c
@ -3216,8 +3216,8 @@ apdu_enum_reader (int slot, int *used)
|
|||||||
int
|
int
|
||||||
apdu_connect (int slot)
|
apdu_connect (int slot)
|
||||||
{
|
{
|
||||||
int sw;
|
int sw = 0;
|
||||||
unsigned int status;
|
unsigned int status = 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;
|
||||||
@ -3234,15 +3234,15 @@ apdu_connect (int slot)
|
|||||||
unlock_slot (slot);
|
unlock_slot (slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
sw = 0;
|
|
||||||
|
|
||||||
/* We need to call apdu_get_status_internal, so that the last-status
|
/* We need to call apdu_get_status_internal, so that the last-status
|
||||||
machinery gets setup properly even if a card is inserted while
|
machinery gets setup properly even if a card is inserted while
|
||||||
scdaemon is fired up and apdu_get_status has not yet been called.
|
scdaemon is fired up and apdu_get_status has not yet been called.
|
||||||
Without that we would force a reset of the card with the next
|
Without that we would force a reset of the card with the next
|
||||||
call to apdu_get_status. */
|
call to apdu_get_status. */
|
||||||
apdu_get_status_internal (slot, 1, 1, &status, NULL);
|
if (!sw)
|
||||||
|
sw = apdu_get_status_internal (slot, 1, 1, &status, NULL);
|
||||||
|
|
||||||
if (sw)
|
if (sw)
|
||||||
;
|
;
|
||||||
else if (!(status & APDU_CARD_PRESENT))
|
else if (!(status & APDU_CARD_PRESENT))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user