From f9d11c9f6b6b073eeb8cf64ebba2e763d6f01c21 Mon Sep 17 00:00:00 2001 From: Francois Beutin Date: Mon, 16 Oct 2023 13:03:30 +0200 Subject: [PATCH] check address len in swap mode Closes #202 --- app/src/swap/handle_check_address.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/swap/handle_check_address.c b/app/src/swap/handle_check_address.c index b861a33f..e2c02c3b 100644 --- a/app/src/swap/handle_check_address.c +++ b/app/src/swap/handle_check_address.c @@ -47,7 +47,10 @@ void handle_check_address(check_address_parameters_t* params) { const uint8_t *address = buffer + PK_LEN_25519; const uint8_t addressLen = replyLen - PK_LEN_25519; - if (addressLen == params->address_parameters_length && + // Exchange guarantees that the input string is '\0' terminated + uint8_t address_to_check_len = strlen(params->address_to_check); + + if (addressLen == address_to_check_len && memcmp(address, params->address_to_check, addressLen) == 0) { params->result = 1; }