From: Thomas Weißschuh Date: Tue, 29 Aug 2023 10:22:28 +0000 (+0200) Subject: libblkid: (zonefs) avoid modifying shared buffer X-Git-Tag: v2.40-rc1~259^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a244fe816101babb08ed3533b6aa04ce62ba30ef;p=thirdparty%2Futil-linux.git libblkid: (zonefs) avoid modifying shared buffer Signed-off-by: Thomas Weißschuh --- diff --git a/libblkid/src/superblocks/zonefs.c b/libblkid/src/superblocks/zonefs.c index b18dc2c6de..8aa45b0d34 100644 --- a/libblkid/src/superblocks/zonefs.c +++ b/libblkid/src/superblocks/zonefs.c @@ -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,