Skip to content

Commit

Permalink
partitioning_systems/gpt: Fix _IsHeaderValid().
Browse files Browse the repository at this point in the history
Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
  • Loading branch information
Josef Gajdusek authored and waddlesplash committed Jul 25, 2015
1 parent e4b8ed4 commit 4a839f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/add-ons/kernel/partitioning_systems/gpt/Header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,24 +290,24 @@ Header::_Read(int fd, off_t offset, void* data, size_t size) const


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))
&& _ValidateHeaderCRC()
&& fHeader.AbsoluteBlock() == block;
return !memcmp(header.header, EFI_PARTITION_HEADER, sizeof(header.header))
&& _ValidateHeaderCRC(header)
&& header.AbsoluteBlock() == block;
}


bool
Header::_ValidateHeaderCRC()
Header::_ValidateHeaderCRC(efi_table_header& header)
{
uint32 originalCRC = fHeader.HeaderCRC();
fHeader.SetHeaderCRC(0);
uint32 originalCRC = header.HeaderCRC();
header.SetHeaderCRC(0);

bool matches = originalCRC == crc32((const uint8*)&fHeader,
bool matches = originalCRC == crc32((const uint8*)&header,
sizeof(efi_table_header));

fHeader.SetHeaderCRC(originalCRC);
header.SetHeaderCRC(originalCRC);
return matches;
}

Expand Down
4 changes: 2 additions & 2 deletions src/add-ons/kernel/partitioning_systems/gpt/Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ class Header {

status_t _Read(int fd, off_t offset, void* data,
size_t size) const;
bool _IsHeaderValid(const efi_table_header& header,
bool _IsHeaderValid(efi_table_header& header,
uint64 block);
bool _ValidateHeaderCRC();
bool _ValidateHeaderCRC(efi_table_header& header);
bool _ValidateEntriesCRC() const;
void _SetBackupHeaderFromPrimary(uint64 lastBlock);
size_t _EntryArraySize() const
Expand Down

0 comments on commit 4a839f2

Please sign in to comment.