From c97dd18c2d06671c67f1ede0e5e7d122296bbc05 Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Thu, 20 Feb 2025 09:09:28 +0100 Subject: [PATCH] fix(core): fix NRF communication long message check [no changelog] --- core/embed/io/nrf/stm32u5/nrf.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/embed/io/nrf/stm32u5/nrf.c b/core/embed/io/nrf/stm32u5/nrf.c index e4dde4f6eb..bf22ab84fd 100644 --- a/core/embed/io/nrf/stm32u5/nrf.c +++ b/core/embed/io/nrf/stm32u5/nrf.c @@ -524,14 +524,13 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *urt) { } else if (drv->rx_idx >= UART_HEADER_SIZE && drv->rx_idx < (drv->rx_len - 1)) { // receive the rest of the message - - drv->rx_buffer.data[drv->rx_idx - UART_HEADER_SIZE] = drv->rx_byte; - drv->rx_idx++; - - if (drv->rx_idx >= NRF_MAX_TX_DATA_SIZE) { + if (drv->rx_idx >= NRF_MAX_TX_DATA_SIZE + UART_HEADER_SIZE) { // message is too long, flush the line drv->rx_idx = 0; drv->rx_len = 0; + } else { + drv->rx_buffer.data[drv->rx_idx - UART_HEADER_SIZE] = drv->rx_byte; + drv->rx_idx++; } } else if (drv->rx_idx == (drv->rx_len - 1)) {