From 986162ed3e8396a4fe4128c9840e4c4ab77161d0 Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Mon, 2 Sep 2024 14:52:08 +0200 Subject: [PATCH] Added missing error-handling in EIP-712 type_hash function --- src_features/signMessageEIP712/type_hash.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src_features/signMessageEIP712/type_hash.c b/src_features/signMessageEIP712/type_hash.c index f37e20820..ac25a68c2 100644 --- a/src_features/signMessageEIP712/type_hash.c +++ b/src_features/signMessageEIP712/type_hash.c @@ -129,7 +129,12 @@ static const void **get_struct_dependencies(uint8_t *const deps_count, // get struct name arg_structname = get_struct_field_typename(field_ptr, &arg_structname_length); // from its name, get the pointer to its definition - arg_struct_ptr = get_structn(arg_structname, arg_structname_length); + if ((arg_struct_ptr = get_structn(arg_structname, arg_structname_length)) == NULL) { + PRINTF("Error: could not find EIP-712 struct \""); + for (int i = 0; i < arg_structname_length; ++i) PRINTF("%c", arg_structname[i]); + PRINTF("\" during type_hash\n"); + return NULL; + } // check if it is not already present in the dependencies array for (dep_idx = 0; dep_idx < *deps_count; ++dep_idx) {