partitioning_systems/gpt: Fix _IsHeaderValid().

Signed-off-by: Augustin Cavalier <[email protected]>
This commit is contained in:
Josef Gajdusek
2015-07-25 10:15:24 -04:00
committed by Augustin Cavalier
parent e4b8ed4a85
commit 4a839f2daa
2 changed files with 11 additions and 11 deletions
@@ -290,24 +290,24 @@ Header::_Read(int fd, off_t offset, void* data, size_t size) const
bool bool
Header::_IsHeaderValid(const efi_table_header& header, uint64 block) Header::_IsHeaderValid(efi_table_header& header, uint64 block)
{ {
return !memcmp(fHeader.header, EFI_PARTITION_HEADER, sizeof(fHeader.header)) return !memcmp(header.header, EFI_PARTITION_HEADER, sizeof(header.header))
&& _ValidateHeaderCRC() && _ValidateHeaderCRC(header)
&& fHeader.AbsoluteBlock() == block; && header.AbsoluteBlock() == block;
} }
bool bool
Header::_ValidateHeaderCRC() Header::_ValidateHeaderCRC(efi_table_header& header)
{ {
uint32 originalCRC = fHeader.HeaderCRC(); uint32 originalCRC = header.HeaderCRC();
fHeader.SetHeaderCRC(0); header.SetHeaderCRC(0);
bool matches = originalCRC == crc32((const uint8*)&fHeader, bool matches = originalCRC == crc32((const uint8*)&header,
sizeof(efi_table_header)); sizeof(efi_table_header));
fHeader.SetHeaderCRC(originalCRC); header.SetHeaderCRC(originalCRC);
return matches; return matches;
} }
@@ -53,9 +53,9 @@ private:
status_t _Read(int fd, off_t offset, void* data, status_t _Read(int fd, off_t offset, void* data,
size_t size) const; size_t size) const;
bool _IsHeaderValid(const efi_table_header& header, bool _IsHeaderValid(efi_table_header& header,
uint64 block); uint64 block);
bool _ValidateHeaderCRC(); bool _ValidateHeaderCRC(efi_table_header& header);
bool _ValidateEntriesCRC() const; bool _ValidateEntriesCRC() const;
void _SetBackupHeaderFromPrimary(uint64 lastBlock); void _SetBackupHeaderFromPrimary(uint64 lastBlock);
size_t _EntryArraySize() const size_t _EntryArraySize() const