summaryrefslogtreecommitdiffstats
path: root/libblkid/src/superblocks/linux_raid.c
diff options
context:
space:
mode:
Diffstat (limited to 'libblkid/src/superblocks/linux_raid.c')
-rw-r--r--libblkid/src/superblocks/linux_raid.c7
1 files changed, 3 insertions, 4 deletions
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;