From b6e4f887cb4af162a9048fd02899c1762a0066f2 Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Wed, 4 May 2022 11:27:51 +0200 Subject: [PATCH] Fixes printf formatting issues caused by the toolchain --- src_features/signMessageEIP712/mem_utils.c | 16 ++++++++-------- src_features/signMessageEIP712/path.c | 4 +++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src_features/signMessageEIP712/mem_utils.c b/src_features/signMessageEIP712/mem_utils.c index 0c5583f..d5d85e1 100644 --- a/src_features/signMessageEIP712/mem_utils.c +++ b/src_features/signMessageEIP712/mem_utils.c @@ -43,15 +43,15 @@ char *mem_alloc_and_format_uint(uint32_t value, size += 1; } // +1 for the null character - if ((mem_ptr = mem_alloc(sizeof(char) * (size + 1))) == NULL) + if ((mem_ptr = mem_alloc(sizeof(char) * (size + 1)))) { - return 0; - } - snprintf(mem_ptr, (size + 1), "%u", value); - mem_dealloc(sizeof(char)); // to skip the null character - if (length != NULL) - { - *length = size; + // should be using %u, but not supported by toolchain + snprintf(mem_ptr, (size + 1), "%d", value); + mem_dealloc(sizeof(char)); // to skip the null character + if (length != NULL) + { + *length = size; + } } return mem_ptr; } diff --git a/src_features/signMessageEIP712/path.c b/src_features/signMessageEIP712/path.c index fd8c54e..8a8ec1f 100644 --- a/src_features/signMessageEIP712/path.c +++ b/src_features/signMessageEIP712/path.c @@ -137,7 +137,9 @@ static bool path_depth_list_pop(void) PRINTF("Hash = 0x"); for (int idx = 0; idx < KECCAK256_HASH_BYTESIZE; ++idx) { - PRINTF("%.02x", shash[idx]); + // manual 0 padding, %.02x not supported by toolchain + if (shash[idx] < 0x10) PRINTF("0"); + PRINTF("%x", shash[idx]); } PRINTF("\n\n"); }