From: Samanta Navarro Date: Sun, 8 Nov 2020 11:45:18 +0000 (+0000) Subject: libblkid: allow a lot of mac partitions X-Git-Tag: v2.36.1~11 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=b134be670d469643c4908cba612bf405396c4dfe;p=thirdparty%2Futil-linux.git libblkid: allow a lot of mac partitions 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 --- diff --git a/libblkid/src/partitions/mac.c b/libblkid/src/partitions/mac.c index 4713d60427..2be91a6205 100644 --- a/libblkid/src/partitions/mac.c +++ b/libblkid/src/partitions/mac.c @@ -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))); }