From bc767e283aa1cbc0bf760c85e10f8846a1ac993f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Thu, 27 Feb 2025 18:15:38 +0100 Subject: [PATCH] libblkid: ddf_raid: respect constness of buffer MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The buffers returned by blkid_probe_get_buffer() are not allowed to be modified. Respect this restriction when casting the buffer to other pointer types. Signed-off-by: Thomas Weißschuh --- libblkid/src/superblocks/ddf_raid.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libblkid/src/superblocks/ddf_raid.c b/libblkid/src/superblocks/ddf_raid.c index a7cf32cf40..f3be815744 100644 --- a/libblkid/src/superblocks/ddf_raid.c +++ b/libblkid/src/superblocks/ddf_raid.c @@ -76,14 +76,14 @@ static int probe_ddf(blkid_probe pr, { int hdrs[] = { 1, 257 }; size_t i; - struct ddf_header *ddf = NULL; + const struct ddf_header *ddf = NULL; char version[DDF_REV_LENGTH + 1]; uint64_t off = 0, lba; for (i = 0; i < ARRAY_SIZE(hdrs); i++) { off = ((pr->size / 0x200) - hdrs[i]) * 0x200; - ddf = (struct ddf_header *) blkid_probe_get_buffer(pr, + ddf = (const struct ddf_header *) blkid_probe_get_buffer(pr, off, sizeof(struct ddf_header)); if (!ddf) @@ -123,7 +123,7 @@ static int probe_ddf(blkid_probe pr, return 1; if (blkid_probe_set_magic(pr, off, sizeof(ddf->signature), - (unsigned char *) &ddf->signature)) + (const unsigned char *) &ddf->signature)) return 1; return 0; } -- 2.47.2