diff options
author | Rostislav Skudnov | 2016-08-30 12:07:49 +0200 |
---|---|---|
committer | Karel Zak | 2016-08-30 13:50:51 +0200 |
commit | f98b563268624a94a7e8a6ed0a6b06b78c676ba1 (patch) | |
tree | 5a0a8c0dda90a04994330f86e7ab651d14095cfb /libblkid/src/superblocks | |
parent | libblkid: ignore empty MBR on LVM device (diff) | |
download | kernel-qcow2-util-linux-f98b563268624a94a7e8a6ed0a6b06b78c676ba1.tar.gz kernel-qcow2-util-linux-f98b563268624a94a7e8a6ed0a6b06b78c676ba1.tar.xz kernel-qcow2-util-linux-f98b563268624a94a7e8a6ed0a6b06b78c676ba1.zip |
libblkid: [exfat] Limit maximum number of iterations in find_label
Do not hang if there is a cluster chain loop in rootdir
[kzak@redhat.com: - add return NULL]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid/src/superblocks')
-rw-r--r-- | libblkid/src/superblocks/exfat.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libblkid/src/superblocks/exfat.c b/libblkid/src/superblocks/exfat.c index 01ed30b78..659e196c2 100644 --- a/libblkid/src/superblocks/exfat.c +++ b/libblkid/src/superblocks/exfat.c @@ -86,8 +86,10 @@ static struct exfat_entry_label *find_label(blkid_probe pr, uint32_t cluster = le32_to_cpu(sb->rootdir_cluster); uint64_t offset = cluster_to_offset(sb, cluster); uint8_t *entry; + const size_t max_iter = 10000; + size_t i = 0; - for (;;) { + for (; i < max_iter; i++) { entry = (uint8_t *) blkid_probe_get_buffer(pr, offset, EXFAT_ENTRY_SIZE); if (!entry) @@ -96,6 +98,7 @@ static struct exfat_entry_label *find_label(blkid_probe pr, return NULL; if (entry[0] == EXFAT_ENTRY_LABEL) return (struct exfat_entry_label *) entry; + offset += EXFAT_ENTRY_SIZE; if (offset % CLUSTER_SIZE(sb) == 0) { cluster = next_cluster(pr, sb, cluster); @@ -106,6 +109,8 @@ static struct exfat_entry_label *find_label(blkid_probe pr, offset = cluster_to_offset(sb, cluster); } } + + return NULL; } static int probe_exfat(blkid_probe pr, const struct blkid_idmag *mag) |