mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-26 14:55:16 +00:00
Merge pull request #1484 from nathan-menhorn/tee-validate-header-603
Update optee_utils.c to fix ARM-software/tf-issues#603
This commit is contained in:
commit
100992b531
1 changed files with 15 additions and 8 deletions
|
@ -25,7 +25,8 @@ typedef struct optee_image {
|
||||||
|
|
||||||
#define OPTEE_PAGER_IMAGE_ID 0
|
#define OPTEE_PAGER_IMAGE_ID 0
|
||||||
#define OPTEE_PAGED_IMAGE_ID 1
|
#define OPTEE_PAGED_IMAGE_ID 1
|
||||||
#define OPTEE_MAX_IMAGE_NUM 2
|
|
||||||
|
#define OPTEE_MAX_NUM_IMAGES 2u
|
||||||
|
|
||||||
#define TEE_MAGIC_NUM_OPTEE 0x4554504f
|
#define TEE_MAGIC_NUM_OPTEE 0x4554504f
|
||||||
/*
|
/*
|
||||||
|
@ -53,14 +54,20 @@ typedef struct optee_header {
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
static inline int tee_validate_header(optee_header_t *header)
|
static inline int tee_validate_header(optee_header_t *header)
|
||||||
{
|
{
|
||||||
|
int valid = 0;
|
||||||
|
|
||||||
if ((header->magic == TEE_MAGIC_NUM_OPTEE) &&
|
if ((header->magic == TEE_MAGIC_NUM_OPTEE) &&
|
||||||
(header->version == 2) &&
|
(header->version == 2u) &&
|
||||||
(header->nb_images <= OPTEE_MAX_IMAGE_NUM)) {
|
(header->nb_images > 0u) &&
|
||||||
return 1;
|
(header->nb_images <= OPTEE_MAX_NUM_IMAGES)) {
|
||||||
|
valid = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
WARN("Not a known TEE, use default loading options.\n");
|
WARN("Not a known TEE, use default loading options.\n");
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
Loading…
Add table
Reference in a new issue