From 64418c52bc594abf01fc4ae8148e7aa93e4b3f22 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 29 Aug 2023 12:22:28 +0200 Subject: [PATCH] libblkid: (zonefs) avoid modifying shared buffer MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Weißschuh --- libblkid/src/superblocks/zonefs.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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, -- 2.47.2