kernel+libluna: Fix the CRC32 algorithm and use it to verify the GPT header
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
16b0531d42
commit
56f3d26969
@ -29,7 +29,6 @@ namespace GPT
|
||||
check(header.reserved == 0);
|
||||
check(header.this_lba == 1);
|
||||
|
||||
#if 0
|
||||
const u32 chksum = checksum_gpt(header);
|
||||
|
||||
if (chksum != header.checksum)
|
||||
@ -37,7 +36,6 @@ namespace GPT
|
||||
kwarnln("gpt: Header checksum does not match, %#.8x != %#.8x!", chksum, header.checksum);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
u64 partition_table_start = header.partition_table_lba * GPT_SECTOR_SIZE;
|
||||
|
||||
|
@ -35,15 +35,13 @@ static const u32 crc_table[] = {
|
||||
|
||||
namespace CRC32
|
||||
{
|
||||
// FIXME: This shouldn't return 0xffffffff when there are 4 zeros in a row somewhere in the data, right? That's what
|
||||
// happens to the GPT header. (other CRC32 implementations don't seem to have this problem)
|
||||
u32 checksum(const u8* data, usize size)
|
||||
{
|
||||
u32 crc = 0xffffffffu;
|
||||
|
||||
for (usize i = 0; i < size; i++)
|
||||
{
|
||||
const u32 index = (crc & data[i]) & 0xff;
|
||||
const u32 index = (crc & 0xff) ^ data[i];
|
||||
crc = (crc >> 8) ^ (crc_table[index]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user