1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

scd: Handle error correctly.

* scd/apdu.c (apdu_connect): Initialize variables and check an error
of apdu_get_status_internal.
This commit is contained in:
NIIBE Yutaka 2015-09-28 13:41:59 +09:00
parent 12ff806d1b
commit 6bb7206e35

View File

@ -3313,8 +3313,8 @@ apdu_enum_reader (int slot, int *used)
int
apdu_connect (int slot)
{
int sw;
unsigned int status;
int sw = 0;
unsigned int status = 0;
if (DBG_READER)
log_debug ("enter: apdu_connect: slot=%d\n", slot);
@ -3338,15 +3338,15 @@ apdu_connect (int slot)
unlock_slot (slot);
}
}
else
sw = 0;
/* We need to call apdu_get_status_internal, so that the last-status
machinery gets setup properly even if a card is inserted while
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
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)
;
else if (!(status & APDU_CARD_PRESENT))