From dda1e20fb38c3663a5be5216911dca49dce61401 Mon Sep 17 00:00:00 2001 From: pscott Date: Fri, 27 Aug 2021 18:35:53 +0200 Subject: [PATCH] Fix V computing when using < 4 bytes chain IDs --- src_features/signTx/ui_common_signTx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src_features/signTx/ui_common_signTx.c b/src_features/signTx/ui_common_signTx.c index dc7e3d8..36a0bd9 100644 --- a/src_features/signTx/ui_common_signTx.c +++ b/src_features/signTx/ui_common_signTx.c @@ -41,9 +41,10 @@ unsigned int io_seproxyhal_touch_tx_ok(__attribute__((unused)) const bagl_elemen // New API // Note that this is wrong for a large v, but ledgerjs will recover. - // Casting to u32 not to introduce breaking changes. In the future, this should be - // updated. - uint32_t v = U4BE(tmpContent.txContent.v, 0); + // Taking only the 4 highest bytes to not introduce breaking changes. In the future, + // this should be updated. + uint32_t v = (uint32_t) u64_from_BE(tmpContent.txContent.v, + MIN(4, tmpContent.txContent.vLength)); G_io_apdu_buffer[0] = (v * 2) + 35; } if (info & CX_ECCINFO_PARITY_ODD) {