]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: vfat: avoid 32-bit overflow in offset calculations
authorKarel Zak <kzak@redhat.com>
Wed, 15 Apr 2026 18:26:25 +0000 (20:26 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 23 Apr 2026 12:07:45 +0000 (14:07 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/superblocks/vfat.c

index 6822bcdba68c325c4f65d63804749ab9e6f32de4..a3ae46a0abba55269191104e8763ae74b2a19cf2 100644 (file)
@@ -328,7 +328,7 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag)
 
        if (ms->ms_fat_length) {
                /* the label may be an attribute in the root directory */
-               uint32_t root_start = (reserved + fat_size) * sector_size;
+               uint64_t root_start = ((uint64_t) reserved + fat_size) * sector_size;
                uint32_t root_dir_entries = unaligned_le16(&vs->vs_dir_entries);
 
                if (search_fat_label(pr, root_start, root_dir_entries, vol_label_buf))
@@ -366,7 +366,7 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag)
                        int count;
 
                        next_sect_off = (next - 2) * vs->vs_cluster_size;
-                       next_off = (uint64_t)(start_data_sect + next_sect_off) *
+                       next_off = ((uint64_t) start_data_sect + next_sect_off) *
                                sector_size;
 
                        count = buf_size / sizeof(struct vfat_dir_entry);