]> 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)
committerYuezhang Mo <Yuezhang.Mo@sony.com>
Wed, 11 Oct 2023 11:02:14 +0000 (19:02 +0800)
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 554868f4f842fe1f9b695db4cb6e80fc21f20582..06ad5c8c02876a8c41a7003cf24b639bbfee6a27 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++) {