From 8bb05ac73a5b448b339ce0bc8d396c82c459b47f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 21:33:32 +0200 Subject: Merging upstream version 2.40. Signed-off-by: Daniel Baumann --- libblkid/src/superblocks/linux_raid.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libblkid/src/superblocks/linux_raid.c') diff --git a/libblkid/src/superblocks/linux_raid.c b/libblkid/src/superblocks/linux_raid.c index 360cd4e..156b0bf 100644 --- a/libblkid/src/superblocks/linux_raid.c +++ b/libblkid/src/superblocks/linux_raid.c @@ -187,15 +187,14 @@ static int raid1_verify_csum(blkid_probe pr, off_t off, { size_t csummed_size = sizeof(struct mdp1_super_block) + le32_to_cpu(mdp1->max_dev) * sizeof(mdp1->dev_roles[0]); - unsigned char *csummed = blkid_probe_get_buffer(pr, off, csummed_size); + const unsigned char *csummed = blkid_probe_get_buffer(pr, off, csummed_size); if (!csummed) return 1; - memset(csummed + offsetof(struct mdp1_super_block, sb_csum), 0, - sizeof(mdp1->sb_csum)); - uint64_t csum = 0; + csum -= le32_to_cpu(*(uint32_t *) (csummed + offsetof(struct mdp1_super_block, sb_csum))); + while (csummed_size >= 4) { csum += le32_to_cpu(*(uint32_t *) csummed); csummed_size -= 4; -- cgit v1.2.3