From c1555c1360eaf1087aac73a08f35e5b60f9aff2f Mon Sep 17 00:00:00 2001 From: Eric Wild Date: Sat, 7 Nov 2020 00:03:18 +0100 Subject: ccid: do not allow xfers with inactive slots pcscd tries to do this if the previous command led to a deactivation... Change-Id: If2659c7d5e8784e5e4393d5b12589e96d517168a --- ccid_common/ccid_device.c | 2 +- ccid_common/ccid_slot_fsm.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ccid_common/ccid_device.c b/ccid_common/ccid_device.c index fe21414..7819d41 100644 --- a/ccid_common/ccid_device.c +++ b/ccid_common/ccid_device.c @@ -462,7 +462,7 @@ static int ccid_handle_xfr_block(struct ccid_slot *cs, struct msgb *msg) /* handle this asynchronously */ rc = cs->ci->slot_ops->xfr_block_async(cs, msg, &u->xfr_block); - if (rc < 0) { + if (rc <= 0) { msgb_trim(msg, sizeof(struct ccid_rdr_to_pc_data_block)); resp = ccid_gen_data_block(cs, u->xfr_block.hdr.bSeq, CCID_CMD_STATUS_FAILED, -rc, 0, 0); goto out; diff --git a/ccid_common/ccid_slot_fsm.c b/ccid_common/ccid_slot_fsm.c index af5b713..043fa8f 100644 --- a/ccid_common/ccid_slot_fsm.c +++ b/ccid_common/ccid_slot_fsm.c @@ -302,12 +302,16 @@ static int iso_fsm_slot_xfr_block_async(struct ccid_slot *cs, struct msgb *msg, if (msgb_length(msg) != xfb->hdr.dwLength + 10) return -1; + /* might be unpowered after failed ppss that led to reset */ + if (cs->icc_powered != true) + return -0; + msgb_pull(msg, 10); LOGPCS(cs, LOGL_DEBUG, "scheduling TPDU transfer: %s\n", msgb_hexdump(msg)); osmo_fsm_inst_dispatch(ss->fi, ISO7816_E_XCEIVE_TPDU_CMD, msg); /* continues in iso_fsm_clot_user_cb once response/error/timeout is received */ - return 0; + return 1; } -- cgit v1.2.3