iso7816_fsm: Fix TPDUs wih Le == 1 (single byte reads)
If we expect only a single byte in response to the TPDU header,
the cuart driver sends us RX_SINGLE events, not RX_COMPLETE events.
Change-Id: I3f025bc88b9aacc07ae87307328cec56efbac2ab
Closes: OS#4741
diff --git a/ccid_common/iso7816_fsm.c b/ccid_common/iso7816_fsm.c
index 307dac3..02e7c0d 100644
--- a/ccid_common/iso7816_fsm.c
+++ b/ccid_common/iso7816_fsm.c
@@ -1273,7 +1273,12 @@
} else {
card_uart_set_rx_threshold(ip->uart, tpduh->p3);
card_uart_ctrl(ip->uart, CUART_CTL_RX_TIMER_HINT, tpduh->p3);
- osmo_fsm_inst_state_chg(fi, TPDU_S_RX_REMAINING, 0, 0);
+ /* if the expected length is only one byte, cuart will issue
+ * TPDU_S_RX_SINGLE instead of TPDU_S_RX_REMAINING (OS#4741) */
+ if (tpduh->p3 == 1)
+ osmo_fsm_inst_state_chg(fi, TPDU_S_RX_SINGLE, 0, 0);
+ else
+ osmo_fsm_inst_state_chg(fi, TPDU_S_RX_REMAINING, 0, 0);
}
} else if (byte == (tpduh->ins ^ 0xFF)) {
/* transmit/recieve single byte then wait for proc */
@@ -1521,7 +1526,8 @@
.name = "RX_SINGLE",
.in_event_mask = S(ISO7816_E_RX_SINGLE),
.out_state_mask = S(TPDU_S_INIT) |
- S(TPDU_S_PROCEDURE),
+ S(TPDU_S_PROCEDURE) |
+ S(TPDU_S_SW1),
.action = tpdu_s_rx_single_action,
},
[TPDU_S_SW1] = {