From: Thomas Weißschuh Date: Thu, 27 Feb 2025 17:15:38 +0000 (+0100) Subject: libblkid: ddf_raid: respect constness of buffer X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bc767e283aa1cbc0bf760c85e10f8846a1ac993f;p=thirdparty%2Futil-linux.git libblkid: ddf_raid: respect constness of buffer 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 --- diff --git a/libblkid/src/superblocks/ddf_raid.c b/libblkid/src/superblocks/ddf_raid.c index a7cf32cf4..f3be81574 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; }