Skip to content

Commit 6935713

Browse files
rizlikdanielinux
authored andcommitted
disk.c: check max number of partition in disk_open_mbr
we never call disk_open_mbr more than once, it was impossible to trigger this bug. Adding for completeness.
1 parent 7ee61ee commit 6935713

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/disk.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ static int disk_open_mbr(struct disk_drive *drive, const uint8_t *mbr_sector)
8181
uint64_t end_bytes = start_bytes +
8282
((uint64_t)pte->lba_size * GPT_SECTOR_SIZE) - 1;
8383

84+
if (n >= MAX_PARTITIONS)
85+
break;
86+
8487
drive->part[n].drv = drive->drv;
8588
drive->part[n].start = start_bytes;
8689
drive->part[n].end = end_bytes;

0 commit comments

Comments
 (0)