Skip to content

Commit

Permalink
blk: fix potential out of bounds access
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
  • Loading branch information
Ivan-Velickovic committed Jan 29, 2025
1 parent 9266b11 commit aa5e3b1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion blk/components/virt.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static void partitions_init()
blk_virt_config_client_t *client = &config.clients[i];
size_t client_partition = client->partition;

if (msdos_mbr.partitions[client_partition].type == MSDOS_MBR_PARTITION_TYPE_EMPTY) {
if (client_partition >= MSDOS_MBR_MAX_PRIMARY_PARTITIONS || msdos_mbr.partitions[client_partition].type == MSDOS_MBR_PARTITION_TYPE_EMPTY) {
/* Partition does not exist */
LOG_BLK_VIRT_ERR(
"Invalid client partition mapping for client %d: partition: %zu, partition does not exist\n", i,
Expand Down

0 comments on commit aa5e3b1

Please sign in to comment.