diff --git a/legacy/firmware/fsm.c b/legacy/firmware/fsm.c index 0cee204b2..7f9ef36b9 100644 --- a/legacy/firmware/fsm.c +++ b/legacy/firmware/fsm.c @@ -98,6 +98,12 @@ static uint8_t msg_resp[MSG_OUT_DECODED_SIZE] __attribute__((aligned)); return; \ } +#define CHECK_UNLOCKED \ + if (!session_isUnlocked()) { \ + layoutHome(); \ + return; \ + } + #define CHECK_PARAM(cond, errormsg) \ if (!(cond)) { \ fsm_sendFailure(FailureType_Failure_DataError, (errormsg)); \ diff --git a/legacy/firmware/fsm_msg_coin.h b/legacy/firmware/fsm_msg_coin.h index 36c5901a7..529b657b2 100644 --- a/legacy/firmware/fsm_msg_coin.h +++ b/legacy/firmware/fsm_msg_coin.h @@ -146,6 +146,8 @@ void fsm_msgSignTx(const SignTx *msg) { } void fsm_msgTxAck(TxAck *msg) { + CHECK_UNLOCKED + CHECK_PARAM(msg->has_tx, _("No transaction provided")); signing_txack(&(msg->tx)); diff --git a/legacy/firmware/fsm_msg_common.h b/legacy/firmware/fsm_msg_common.h index e9195a964..3c18fe599 100644 --- a/legacy/firmware/fsm_msg_common.h +++ b/legacy/firmware/fsm_msg_common.h @@ -504,7 +504,11 @@ void fsm_msgRecoveryDevice(const RecoveryDevice *msg) { msg->has_u2f_counter ? msg->u2f_counter : 0, dry_run); } -void fsm_msgWordAck(const WordAck *msg) { recovery_word(msg->word); } +void fsm_msgWordAck(const WordAck *msg) { + CHECK_UNLOCKED + + recovery_word(msg->word); +} void fsm_msgSetU2FCounter(const SetU2FCounter *msg) { layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL, diff --git a/legacy/firmware/fsm_msg_ethereum.h b/legacy/firmware/fsm_msg_ethereum.h index 383433534..a03b66294 100644 --- a/legacy/firmware/fsm_msg_ethereum.h +++ b/legacy/firmware/fsm_msg_ethereum.h @@ -125,6 +125,8 @@ void fsm_msgEthereumSignTxEIP1559(const EthereumSignTxEIP1559 *msg) { } void fsm_msgEthereumTxAck(const EthereumTxAck *msg) { + CHECK_UNLOCKED + ethereum_signing_txack(msg); } diff --git a/legacy/firmware/fsm_msg_stellar.h b/legacy/firmware/fsm_msg_stellar.h index 44d920d87..b2ab413e6 100644 --- a/legacy/firmware/fsm_msg_stellar.h +++ b/legacy/firmware/fsm_msg_stellar.h @@ -97,6 +97,8 @@ void fsm_msgStellarSignTx(const StellarSignTx *msg) { } void fsm_msgStellarCreateAccountOp(const StellarCreateAccountOp *msg) { + CHECK_UNLOCKED + if (!stellar_confirmCreateAccountOp(msg)) return; if (stellar_allOperationsConfirmed()) { @@ -115,6 +117,8 @@ void fsm_msgStellarCreateAccountOp(const StellarCreateAccountOp *msg) { } void fsm_msgStellarPaymentOp(const StellarPaymentOp *msg) { + CHECK_UNLOCKED + // This will display additional dialogs to the user if (!stellar_confirmPaymentOp(msg)) return; @@ -136,6 +140,8 @@ void fsm_msgStellarPaymentOp(const StellarPaymentOp *msg) { void fsm_msgStellarPathPaymentStrictReceiveOp( const StellarPathPaymentStrictReceiveOp *msg) { + CHECK_UNLOCKED + if (!stellar_confirmPathPaymentStrictReceiveOp(msg)) return; if (stellar_allOperationsConfirmed()) { @@ -155,6 +161,8 @@ void fsm_msgStellarPathPaymentStrictReceiveOp( void fsm_msgStellarPathPaymentStrictSendOp( const StellarPathPaymentStrictSendOp *msg) { + CHECK_UNLOCKED + if (!stellar_confirmPathPaymentStrictSendOp(msg)) return; if (stellar_allOperationsConfirmed()) { @@ -173,6 +181,8 @@ void fsm_msgStellarPathPaymentStrictSendOp( } void fsm_msgStellarManageBuyOfferOp(const StellarManageBuyOfferOp *msg) { + CHECK_UNLOCKED + if (!stellar_confirmManageBuyOfferOp(msg)) return; if (stellar_allOperationsConfirmed()) { @@ -191,6 +201,8 @@ void fsm_msgStellarManageBuyOfferOp(const StellarManageBuyOfferOp *msg) { } void fsm_msgStellarManageSellOfferOp(const StellarManageSellOfferOp *msg) { + CHECK_UNLOCKED + if (!stellar_confirmManageSellOfferOp(msg)) return; if (stellar_allOperationsConfirmed()) { @@ -210,6 +222,8 @@ void fsm_msgStellarManageSellOfferOp(const StellarManageSellOfferOp *msg) { void fsm_msgStellarCreatePassiveSellOfferOp( const StellarCreatePassiveSellOfferOp *msg) { + CHECK_UNLOCKED + if (!stellar_confirmCreatePassiveSellOfferOp(msg)) return; if (stellar_allOperationsConfirmed()) { @@ -228,6 +242,8 @@ void fsm_msgStellarCreatePassiveSellOfferOp( } void fsm_msgStellarSetOptionsOp(const StellarSetOptionsOp *msg) { + CHECK_UNLOCKED + if (!stellar_confirmSetOptionsOp(msg)) return; if (stellar_allOperationsConfirmed()) { @@ -246,6 +262,8 @@ void fsm_msgStellarSetOptionsOp(const StellarSetOptionsOp *msg) { } void fsm_msgStellarChangeTrustOp(const StellarChangeTrustOp *msg) { + CHECK_UNLOCKED + if (!stellar_confirmChangeTrustOp(msg)) return; if (stellar_allOperationsConfirmed()) { @@ -264,6 +282,8 @@ void fsm_msgStellarChangeTrustOp(const StellarChangeTrustOp *msg) { } void fsm_msgStellarAllowTrustOp(const StellarAllowTrustOp *msg) { + CHECK_UNLOCKED + if (!stellar_confirmAllowTrustOp(msg)) return; if (stellar_allOperationsConfirmed()) { @@ -282,6 +302,8 @@ void fsm_msgStellarAllowTrustOp(const StellarAllowTrustOp *msg) { } void fsm_msgStellarAccountMergeOp(const StellarAccountMergeOp *msg) { + CHECK_UNLOCKED + if (!stellar_confirmAccountMergeOp(msg)) return; if (stellar_allOperationsConfirmed()) { @@ -300,6 +322,8 @@ void fsm_msgStellarAccountMergeOp(const StellarAccountMergeOp *msg) { } void fsm_msgStellarManageDataOp(const StellarManageDataOp *msg) { + CHECK_UNLOCKED + if (!stellar_confirmManageDataOp(msg)) return; if (stellar_allOperationsConfirmed()) { @@ -318,6 +342,8 @@ void fsm_msgStellarManageDataOp(const StellarManageDataOp *msg) { } void fsm_msgStellarBumpSequenceOp(const StellarBumpSequenceOp *msg) { + CHECK_UNLOCKED + if (!stellar_confirmBumpSequenceOp(msg)) return; if (stellar_allOperationsConfirmed()) {