aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Wild <ewild@sysmocom.de>2020-11-07 00:03:18 +0100
committerlaforge <laforge@osmocom.org>2020-11-09 10:58:03 +0000
commitc1555c1360eaf1087aac73a08f35e5b60f9aff2f (patch)
tree71023927db9d204051465274ddd434f94764eddc
parent4c769e9a7dc724ea13bd856e831bea7eb0b1b7ca (diff)
ccid: do not allow xfers with inactive slots
pcscd tries to do this if the previous command led to a deactivation... Change-Id: If2659c7d5e8784e5e4393d5b12589e96d517168a
-rw-r--r--ccid_common/ccid_device.c2
-rw-r--r--ccid_common/ccid_slot_fsm.c6
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;
}