]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: fix misaligned-address in probe_exfat
authorMilan Broz <gmazyland@gmail.com>
Thu, 24 Nov 2022 09:54:01 +0000 (10:54 +0100)
committerMilan Broz <gmazyland@gmail.com>
Thu, 24 Nov 2022 09:58:52 +0000 (10:58 +0100)
Value checked in le32_to_cpu() needs to be properly
aligned. Just copy the value temporarily for conversion.

Fix OSS-Fuzz issue 53696

libblkid/src/superblocks/exfat.c

index e760604908dc5ebae62257945709ad7ca91d4bc9..3703404874d7caa4ed1ef4f2344ec302fea918d6 100644 (file)
@@ -72,16 +72,17 @@ static uint64_t cluster_to_offset(const struct exfat_super_block *sb,
 static uint32_t next_cluster(blkid_probe pr,
                const struct exfat_super_block *sb, uint32_t cluster)
 {
-       uint32_t *next;
+       uint32_t *nextp, next;
        uint64_t fat_offset;
 
        fat_offset = block_to_offset(sb, le32_to_cpu(sb->FatOffset))
                + (uint64_t) cluster * sizeof(cluster);
-       next = (uint32_t *) blkid_probe_get_buffer(pr, fat_offset,
+       nextp = (uint32_t *) blkid_probe_get_buffer(pr, fat_offset,
                        sizeof(uint32_t));
-       if (!next)
+       if (!nextp)
                return 0;
-       return le32_to_cpu(*next);
+       memcpy(&next, nextp, sizeof(next));
+       return le32_to_cpu(next);
 }
 
 static struct exfat_entry_label *find_label(blkid_probe pr,