From: Yuezhang Mo Date: Wed, 11 Oct 2023 10:42:11 +0000 (+0800) Subject: libblkid: exfat: fix fail to find volume label X-Git-Tag: v2.40-rc1~204^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=07b2450d1eda5ecaaeaac1940b606542f5a738d4;p=thirdparty%2Futil-linux.git libblkid: exfat: fix fail to find volume label 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 Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru --- diff --git a/libblkid/src/superblocks/exfat.c b/libblkid/src/superblocks/exfat.c index 554868f4f8..06ad5c8c02 100644 --- a/libblkid/src/superblocks/exfat.c +++ b/libblkid/src/superblocks/exfat.c @@ -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++) {