Better EIP-712 array error-handling on APDU parsing

This commit is contained in:
Alexandre Paillier
2022-07-18 16:18:19 +02:00
parent 5e5b3c3621
commit 0cf21cdf73
2 changed files with 7 additions and 1 deletions

View File

@@ -659,6 +659,11 @@ static bool set_struct_field_array(const uint8_t *const data,
return false;
}
*array_level = data[(*data_idx)++];
if (*array_level > ARRAY_TYPES_COUNT)
{
apdu_response_code = APDU_RESPONSE_INVALID_DATA;
return false;
}
switch (*array_level)
{
case ARRAY_DYNAMIC: // nothing to do

View File

@@ -16,7 +16,8 @@
typedef enum
{
ARRAY_DYNAMIC = 0,
ARRAY_FIXED_SIZE
ARRAY_FIXED_SIZE,
ARRAY_TYPES_COUNT
} e_array_type;
typedef enum