]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: allow a lot of mac partitions
authorSamanta Navarro <ferivoz@riseup.net>
Sun, 8 Nov 2020 11:45:18 +0000 (11:45 +0000)
committerKarel Zak <kzak@redhat.com>
Fri, 13 Nov 2020 11:36:12 +0000 (12:36 +0100)
If the map count is set to INT_MAX then the for loop does not stop
because its check is never false.

I have not found a correct upper limit. The other partition logics have
a maximum amount (exception is atari.c).

The loop itself wouldn't be endless. If the iteration reaches block 0
then the signature will be wrong. This means that map count = INT_MAX
case would fail even if such a setup would be correct on disk.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
libblkid/src/partitions/mac.c

index 4713d60427b5b538a8789cb3100c285f653ff185..2be91a6205c6d52a264c9707e52a292c2d863bd2 100644 (file)
@@ -123,12 +123,12 @@ static int probe_mac_pt(blkid_probe pr,
        ssf = block_size / 512;
        nblks = be32_to_cpu(p->map_count);
 
-       for (i = 1; i <= nblks; ++i) {
+       for (i = 0; i < nblks; ++i) {
                blkid_partition par;
                uint32_t start;
                uint32_t size;
 
-               p = (struct mac_partition *) get_mac_block(pr, block_size, i);
+               p = (struct mac_partition *) get_mac_block(pr, block_size, i + 1);
                if (!p) {
                        if (errno)
                                return -errno;
@@ -141,7 +141,7 @@ static int probe_mac_pt(blkid_probe pr,
                        DBG(LOWPROBE, ul_debug(
                                "mac: inconsistent map_count in partition map, "
                                "entry[0]: %d, entry[%d]: %d",
-                               nblks, i - 1,
+                               nblks, i,
                                be32_to_cpu(p->map_count)));
                }