Skip to content

Commit 7488e5a

Browse files
Fix potential memory leak with incorrect EIP-7702 TLV struct
1 parent f647236 commit 7488e5a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src_features/signAuthorizationEIP7702/commands_7702.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ uint16_t hashRLP64(uint64_t data, uint8_t *rlpTmp, uint8_t rlpTmpLength) {
6060
static bool handleAuth7702TLV(const uint8_t *payload, uint16_t size, bool to_free) {
6161
s_auth_7702_ctx auth_7702_ctx = {0};
6262
s_auth_7702 *auth7702 = &auth_7702_ctx.auth_7702;
63+
bool parsing_ret;
6364
uint8_t rlpDataSize = 0;
6465
uint8_t rlpTmp[40];
6566
uint8_t hashSize;
@@ -71,11 +72,10 @@ static bool handleAuth7702TLV(const uint8_t *payload, uint16_t size, bool to_fre
7172
const char *delegateName;
7273
#endif
7374

74-
if (!tlv_parse(payload, size, (f_tlv_data_handler) handle_auth_7702_struct, &auth_7702_ctx)) {
75-
return false;
76-
}
75+
parsing_ret =
76+
tlv_parse(payload, size, (f_tlv_data_handler) handle_auth_7702_struct, &auth_7702_ctx);
7777
if (to_free) mem_dealloc(size);
78-
if (!verify_auth_7702_struct(&auth_7702_ctx)) {
78+
if (!parsing_ret || !verify_auth_7702_struct(&auth_7702_ctx)) {
7979
return false;
8080
}
8181

0 commit comments

Comments
 (0)