diff options
author | Samuel Bowman <sam@sambowman.tech> | 2022-06-28 19:06:05 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-07-21 20:13:44 +0100 |
commit | 2f8c20816edd695b6e2fe54b3e9a89bd9d8e2efd (patch) | |
tree | 19336494c69d61b4d75d08a5a3ba71bd76a5faa4 | |
parent | fb4221ad52f9c03edebc96e070ebbde25e8c50fb (diff) | |
download | serenity-2f8c20816edd695b6e2fe54b3e9a89bd9d8e2efd.zip |
LibPartition: Fix end block off by one error
Previously, end block was inconsistent. GUIDPartitionTable treated
end block as an inclusive bound, while MBRPartitionTable and
EBRPartitionTable treated end block as an exclusive bound.
Now all three treat end block as an inclusive upper bound.
-rw-r--r-- | Userland/Applications/PartitionEditor/PartitionModel.cpp | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibPartition/EBRPartitionTable.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibPartition/MBRPartitionTable.cpp | 4 |
3 files changed, 3 insertions, 6 deletions
diff --git a/Userland/Applications/PartitionEditor/PartitionModel.cpp b/Userland/Applications/PartitionEditor/PartitionModel.cpp index d0dae293a8..3b03c998e7 100644 --- a/Userland/Applications/PartitionEditor/PartitionModel.cpp +++ b/Userland/Applications/PartitionEditor/PartitionModel.cpp @@ -42,9 +42,6 @@ GUI::Variant PartitionModel::data(GUI::ModelIndex const& index, GUI::ModelRole r case Column::StartBlock: return partition.start_block(); case Column::EndBlock: - // FIXME: Either MBR end block is off by one (if supposed to be exclusive bound) - // or GPT end block is off by one (if supposed to be inclusive bound). - // This is an issue in LibPartition. return partition.end_block(); default: VERIFY_NOT_REACHED(); diff --git a/Userland/Libraries/LibPartition/EBRPartitionTable.cpp b/Userland/Libraries/LibPartition/EBRPartitionTable.cpp index 3335a1516d..74d873b51b 100644 --- a/Userland/Libraries/LibPartition/EBRPartitionTable.cpp +++ b/Userland/Libraries/LibPartition/EBRPartitionTable.cpp @@ -77,7 +77,7 @@ EBRPartitionTable::EBRPartitionTable(NonnullRefPtr<Core::File> device) if (entry.offset == 0x00) { continue; } - MUST(m_partitions.try_empend(entry.offset, (entry.offset + entry.length), entry.type)); + MUST(m_partitions.try_empend(entry.offset, (entry.offset + entry.length) - 1, entry.type)); } } diff --git a/Userland/Libraries/LibPartition/MBRPartitionTable.cpp b/Userland/Libraries/LibPartition/MBRPartitionTable.cpp index 2504ee1457..9ba3a27147 100644 --- a/Userland/Libraries/LibPartition/MBRPartitionTable.cpp +++ b/Userland/Libraries/LibPartition/MBRPartitionTable.cpp @@ -82,7 +82,7 @@ MBRPartitionTable::MBRPartitionTable(NonnullRefPtr<Core::File> device_file, u32 if (entry.offset == 0x00) { continue; } - MUST(m_partitions.try_empend(entry.offset, (entry.offset + entry.length), entry.type)); + MUST(m_partitions.try_empend(entry.offset, (entry.offset + entry.length) - 1, entry.type)); } m_valid = true; } @@ -106,7 +106,7 @@ MBRPartitionTable::MBRPartitionTable(NonnullRefPtr<Core::File> device_file) if (entry.offset == 0x00) { continue; } - MUST(m_partitions.try_empend(entry.offset, (entry.offset + entry.length), entry.type)); + MUST(m_partitions.try_empend(entry.offset, (entry.offset + entry.length) - 1, entry.type)); } m_valid = true; } |