From 174d35782f739d2da5beeec2006831fae79b4d30 Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Wed, 26 Oct 2022 14:15:09 +0200 Subject: [PATCH] Review fixes --- src_features/signMessageEIP712/commands_712.c | 3 ++- src_features/signMessageEIP712/format_hash_field_type.c | 3 ++- src_features/signMessageEIP712/path.c | 2 +- src_features/signMessageEIP712/type_hash.c | 2 +- src_features/signMessageEIP712/ui_logic.c | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src_features/signMessageEIP712/commands_712.c b/src_features/signMessageEIP712/commands_712.c index 3c0cc9e..7810b93 100644 --- a/src_features/signMessageEIP712/commands_712.c +++ b/src_features/signMessageEIP712/commands_712.c @@ -94,7 +94,8 @@ bool handle_eip712_struct_impl(const uint8_t *const apdu_buf) { switch (apdu_buf[OFFSET_P2]) { case P2_IMPL_NAME: // set root type - if ((ret = path_set_root((char *) &apdu_buf[OFFSET_CDATA], apdu_buf[OFFSET_LC]))) { + ret = path_set_root((char *) &apdu_buf[OFFSET_CDATA], apdu_buf[OFFSET_LC]); + if (ret) { if (N_storage.verbose_eip712) { ui_712_review_struct(path_get_root()); reply_apdu = false; diff --git a/src_features/signMessageEIP712/format_hash_field_type.c b/src_features/signMessageEIP712/format_hash_field_type.c index 761f5f3..1760c7d 100644 --- a/src_features/signMessageEIP712/format_hash_field_type.c +++ b/src_features/signMessageEIP712/format_hash_field_type.c @@ -33,7 +33,8 @@ static bool format_hash_field_type_size(const void *const field_ptr, cx_hash_t * apdu_response_code = APDU_RESPONSE_INVALID_DATA; return false; } - if ((uint_str_ptr = mem_alloc_and_format_uint(field_size, &uint_str_len)) == NULL) { + uint_str_ptr = mem_alloc_and_format_uint(field_size, &uint_str_len); + if (uint_str_ptr == NULL) { apdu_response_code = APDU_RESPONSE_INSUFFICIENT_MEMORY; return false; } diff --git a/src_features/signMessageEIP712/path.c b/src_features/signMessageEIP712/path.c index 53eddf3..ec95242 100644 --- a/src_features/signMessageEIP712/path.c +++ b/src_features/signMessageEIP712/path.c @@ -136,7 +136,7 @@ static bool path_depth_list_push(void) { * @return pointer to the hashing context */ static cx_sha3_t *get_last_hash_ctx(void) { - return (cx_sha3_t *) mem_alloc(0) - 1; + return ((cx_sha3_t *) mem_alloc(0)) - 1; } /** diff --git a/src_features/signMessageEIP712/type_hash.c b/src_features/signMessageEIP712/type_hash.c index c70383d..1e8da4b 100644 --- a/src_features/signMessageEIP712/type_hash.c +++ b/src_features/signMessageEIP712/type_hash.c @@ -111,7 +111,7 @@ static void sort_dependencies(uint8_t deps_count, const void **deps) { * @param[out] deps_count count of how many struct dependencie pointers * @param[in] first_dep pointer to the first dependency pointer * @param[in] struct_ptr pointer to the struct we are getting the dependencies of - * @return \ref false in case of a memory allocation error, \ref true otherwise + * @return pointer to the first found dependency, \ref NULL otherwise */ static const void **get_struct_dependencies(uint8_t *const deps_count, const void **first_dep, diff --git a/src_features/signMessageEIP712/ui_logic.c b/src_features/signMessageEIP712/ui_logic.c index 6243134..698e5e1 100644 --- a/src_features/signMessageEIP712/ui_logic.c +++ b/src_features/signMessageEIP712/ui_logic.c @@ -64,7 +64,7 @@ static void ui_712_set_buf(const char *const src, } memcpy(dst, src, cpy_length); dst[cpy_length] = '\0'; - if (explicit_trunc && (src_length > dst_length)) { + if (explicit_trunc && (cpy_length < src_length)) { memcpy(dst + cpy_length - 3, "...", 3); } }