]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: (zonefs) avoid modifying shared buffer
authorThomas Weißschuh <thomas@t-8ch.de>
Tue, 29 Aug 2023 10:22:28 +0000 (12:22 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 24 Nov 2023 09:33:12 +0000 (10:33 +0100)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
libblkid/src/superblocks/zonefs.c

index b18dc2c6deb7bcda8a24a4535f9dbd94d4b3a9cc..8aa45b0d34b3e04faad504a9b46e0c771fb25138 100644 (file)
@@ -49,18 +49,19 @@ struct zonefs_super {
 
 } __attribute__ ((packed));
 
-static int zonefs_verify_csum(blkid_probe pr, struct zonefs_super *sb)
+static int zonefs_verify_csum(blkid_probe pr, const struct zonefs_super *sb)
 {
        uint32_t expected = le32_to_cpu(sb->s_crc);
-       sb->s_crc = 0;
-       uint32_t crc = ul_crc32(~0LL, (unsigned char *) sb, sizeof(*sb));
+       uint32_t crc = ul_crc32_exclude_offset(
+                       ~0LL, (unsigned char *) sb, sizeof(*sb),
+                      offsetof(typeof(*sb), s_crc), sizeof(sb->s_crc));
        return blkid_probe_verify_csum(pr, crc, expected);
 }
 
 static int probe_zonefs(blkid_probe pr,
                const struct blkid_idmag *mag  __attribute__((__unused__)))
 {
-       struct zonefs_super *sb;
+       const struct zonefs_super *sb;
 
        sb = (struct zonefs_super *)
                blkid_probe_get_buffer(pr, ZONEFS_SB_OFST,