1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-04-20 10:17:05 +00:00

Eliminate risk of overrun.

This commit is contained in:
Thomas Harte
2025-04-22 22:50:38 -04:00
parent e78c1bbec9
commit cfc5ef4a3c
+1 -1
View File
@@ -118,7 +118,7 @@ std::optional<FAT::Volume> FAT::GetVolume(const std::shared_ptr<Storage::Disk::D
// Decode the FAT.
// TODO: stop assuming FAT12 here.
for(size_t c = 0; c < source_fat.size(); c += 3) {
for(size_t c = 0; c < source_fat.size() - 2; c += 3) {
const uint32_t double_cluster = uint32_t(source_fat[c] + (source_fat[c + 1] << 8) + (source_fat[c + 2] << 16));
volume.fat.push_back(uint16_t(double_cluster & 0xfff));
volume.fat.push_back(uint16_t(double_cluster >> 12));