btrfs: Fix pointer arithmetic in WriteSuperBlock()

The checksum was being calculated over the wrong memory region.
&fSuperBlock+N advances by N*sizeof(btrfs_super_block) bytes,
not N bytes. The correct form is (uint8*)&fSuperBlock+N which
advances by exactly N bytes past the start of the superblock,
correctly skipping the checksum field.

Change-Id: I8dba6410f2cd2d2d66e3cf484d4ac1f599449021
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10447
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
anujbillore-0-0
2026-03-10 12:24:28 +00:00
committed by Adrien Destugues
parent d7d78c9749
commit d754d09549
@@ -510,7 +510,7 @@ status_t
Volume::WriteSuperBlock()
{
uint32 checksum = calculate_crc((uint32)~1,
(uint8 *)(&fSuperBlock + sizeof(fSuperBlock.checksum)),
(uint8 *)&fSuperBlock + sizeof(fSuperBlock.checksum),
sizeof(fSuperBlock) - sizeof(fSuperBlock.checksum));
fSuperBlock.checksum[0] = (checksum >> 0) & 0xFF;