]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: exfat: fix fail to find volume label
authorYuezhang Mo <Yuezhang.Mo@sony.com>
Wed, 11 Oct 2023 10:42:11 +0000 (18:42 +0800)
committerKarel Zak <kzak@redhat.com>
Fri, 24 Nov 2023 10:09:30 +0000 (11:09 +0100)
Commit f98b56326 set the maximum number of iterations to 10000.
If the volume label is after the 10000th entry, the volume label
will not be found. So this commit sets the maximum number of
iterations to correct value 256×1024×1024/32.

Fixes: f98b56326 ("libblkid: [exfat] Limit maximum number of iterations in find_label")
Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Reviewed-by: Andy Wu <Andy.Wu@sony.com>
Reviewed-by: Aoyama Wataru <wataru.aoyama@sony.com>
libblkid/src/superblocks/exfat.c

index 3703404874d7caa4ed1ef4f2344ec302fea918d6..fda1ecda8bd4b067b9280536556eb1e0becf23bc 100644 (file)
@@ -49,6 +49,8 @@ struct exfat_entry_label {
 #define EXFAT_ENTRY_EOD                0x00
 #define EXFAT_ENTRY_LABEL      0x83
 
+#define EXFAT_MAX_DIR_SIZE     (256 * 1024 * 1024)
+
 static uint64_t block_to_offset(const struct exfat_super_block *sb,
                uint64_t block)
 {
@@ -91,7 +93,7 @@ static struct exfat_entry_label *find_label(blkid_probe pr,
        uint32_t cluster = le32_to_cpu(sb->FirstClusterOfRootDirectory);
        uint64_t offset = cluster_to_offset(sb, cluster);
        uint8_t *entry;
-       const size_t max_iter = 10000;
+       const size_t max_iter = EXFAT_MAX_DIR_SIZE / EXFAT_ENTRY_SIZE;
        size_t i = 0;
 
        for (; i < max_iter; i++) {