@@ -31,28 +31,37 @@ static bool handle_version(const s_tlv_data *data, s_auth_7702_ctx *context) {
31
31
}
32
32
33
33
static bool handle_delegate_addr (const s_tlv_data * data , s_auth_7702_ctx * context ) {
34
- if (data -> length != sizeof (context -> auth_7702 .delegate )) {
34
+ uint8_t buf [sizeof (context -> auth_7702 .delegate )];
35
+
36
+ if (data -> length > sizeof (buf )) {
35
37
return false;
36
38
}
37
- memmove (context -> auth_7702 .delegate , data -> value , sizeof (context -> auth_7702 .delegate ));
39
+ buf_shrink_expand (data -> value , data -> length , buf , sizeof (buf ));
40
+ memmove (context -> auth_7702 .delegate , buf , sizeof (buf ));
38
41
context -> mask_parsed |= SET_BIT (BIT_DELEGATE_ADDR );
39
42
return true;
40
43
}
41
44
42
45
static bool handle_chain_id (const s_tlv_data * data , s_auth_7702_ctx * context ) {
43
- if (data -> length != sizeof (uint64_t )) {
46
+ uint8_t buf [sizeof (context -> auth_7702 .chainId )];
47
+
48
+ if (data -> length > sizeof (buf )) {
44
49
return false;
45
50
}
46
- context -> auth_7702 .chainId = read_u64_be (data -> value , 0 );
51
+ buf_shrink_expand (data -> value , data -> length , buf , sizeof (buf ));
52
+ context -> auth_7702 .chainId = read_u64_be (buf , 0 );
47
53
context -> mask_parsed |= SET_BIT (BIT_CHAIN_ID );
48
54
return true;
49
55
}
50
56
51
57
static bool handle_nonce (const s_tlv_data * data , s_auth_7702_ctx * context ) {
52
- if (data -> length != sizeof (uint64_t )) {
58
+ uint8_t buf [sizeof (context -> auth_7702 .nonce )];
59
+
60
+ if (data -> length > sizeof (buf )) {
53
61
return false;
54
62
}
55
- context -> auth_7702 .nonce = read_u64_be (data -> value , 0 );
63
+ buf_shrink_expand (data -> value , data -> length , buf , sizeof (buf ));
64
+ context -> auth_7702 .nonce = read_u64_be (buf , 0 );
56
65
context -> mask_parsed |= SET_BIT (BIT_NONCE );
57
66
return true;
58
67
}
0 commit comments