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>
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;
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)));
}