diff --git a/components/drivers/block/partitions/efi.c b/components/drivers/block/partitions/efi.c index 22f6ba16591..a2947bdeda2 100644 --- a/components/drivers/block/partitions/efi.c +++ b/components/drivers/block/partitions/efi.c @@ -454,9 +454,13 @@ static rt_bool_t is_gpt_valid(struct rt_blk_disk *disk, */ rt_inline rt_bool_t is_pte_valid(const gpt_entry *pte, const rt_size_t lastlba) { + rt_uint64_t start = rt_le64_to_cpu(pte->starting_lba); + rt_uint64_t end = rt_le64_to_cpu(pte->ending_lba); + if ((!efi_guidcmp(pte->partition_type_guid, NULL_GUID)) || - rt_le64_to_cpu(pte->starting_lba) > lastlba || - rt_le64_to_cpu(pte->ending_lba) > lastlba) + start > lastlba || + end > lastlba || + end < start) { return RT_FALSE; }