Explorar o código

[dm][block] fixup the EFI partition checked in 32bits

Link: https://github.com/RT-Thread/rt-thread/issues/11260

Signed-off-by: GuEe-GUI <2991707448@qq.com>
GuEe-GUI hai 2 días
pai
achega
2b58dec87b
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  1. 5 0
      components/drivers/block/partitions/efi.c

+ 5 - 0
components/drivers/block/partitions/efi.c

@@ -411,6 +411,11 @@ static rt_bool_t is_gpt_valid(struct rt_blk_disk *disk,
     pt_size = (rt_uint64_t)rt_le32_to_cpu((*gpt)->num_partition_entries) *
     pt_size = (rt_uint64_t)rt_le32_to_cpu((*gpt)->num_partition_entries) *
             rt_le32_to_cpu((*gpt)->sizeof_partition_entry);
             rt_le32_to_cpu((*gpt)->sizeof_partition_entry);
 
 
+    if (pt_size > (rt_uint64_t)RT_UINT32_MAX)
+    {
+        goto _fail;
+    }
+
     if (!(*ptes = alloc_read_gpt_entries(disk, *gpt)))
     if (!(*ptes = alloc_read_gpt_entries(disk, *gpt)))
     {
     {
         goto _fail;
         goto _fail;