Skip to content

Commit eda8173

Browse files
authored
Fix multiplication overflow
The sd_card_info.sector_count and sd_card_info.sector_size_bytes variables are both 32 bit, so the multiplication overflows for large block devices.
1 parent 8d40a8a commit eda8173

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libraries/BlockDevices/SDCardBlockDevice.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ int SDCardBlockDevice::open() {
313313
read_block_size = sd_card_info.sector_size_bytes;
314314
erase_block_size = sd_card_info.sector_size_bytes;
315315
write_block_size = sd_card_info.sector_size_bytes;
316-
total_size = sd_card_info.sector_count * sd_card_info.sector_size_bytes;
316+
total_size = (bd_size_t) sd_card_info.sector_count * (bd_size_t) sd_card_info.sector_size_bytes;
317317

318318
}
319319
}

0 commit comments

Comments
 (0)