aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2015-09-28 04:41:59 +0000
committerNIIBE Yutaka <[email protected]>2016-11-29 07:55:49 +0000
commitaf7245e9a79d11866aa9c40f8f53291f82dd74b5 (patch)
treea9ff891e144772c2d92b7370b49c1ad5b67a9a7e
parentscd: KEYNO cleanup. (diff)
downloadgnupg-af7245e9a79d11866aa9c40f8f53291f82dd74b5.tar.gz
gnupg-af7245e9a79d11866aa9c40f8f53291f82dd74b5.zip
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
-rw-r--r--scd/apdu.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/scd/apdu.c b/scd/apdu.c
index 30e5ef9c3..00351c82a 100644
--- a/scd/apdu.c
+++ b/scd/apdu.c
@@ -3216,8 +3216,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 (slot < 0 || slot >= MAX_READER || !reader_table[slot].used )
return SW_HOST_NO_DRIVER;
@@ -3234,15 +3234,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))