Blame SOURCES/0078-libblkid-allow-a-lot-of-mac-partitions.patch

14604f
From 2348779e225dd581c32c00108e017f5c1924e706 Mon Sep 17 00:00:00 2001
14604f
From: Samanta Navarro <ferivoz@riseup.net>
14604f
Date: Sun, 8 Nov 2020 11:45:18 +0000
14604f
Subject: libblkid: allow a lot of mac partitions
14604f
14604f
If the map count is set to INT_MAX then the for loop does not stop
14604f
because its check is never false.
14604f
14604f
I have not found a correct upper limit. The other partition logics have
14604f
a maximum amount (exception is atari.c).
14604f
14604f
The loop itself wouldn't be endless. If the iteration reaches block 0
14604f
then the signature will be wrong. This means that map count = INT_MAX
14604f
case would fail even if such a setup would be correct on disk.
14604f
14604f
Upstream: http://github.com/util-linux/util-linux/commit/8f22adaaf30e9fd3bf83da0213b4a6525c9305cd
14604f
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2060030
14604f
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
14604f
---
14604f
 libblkid/src/partitions/mac.c | 6 +++---
14604f
 1 file changed, 3 insertions(+), 3 deletions(-)
14604f
14604f
diff --git a/libblkid/src/partitions/mac.c b/libblkid/src/partitions/mac.c
14604f
index 4713d6042..2be91a620 100644
14604f
--- a/libblkid/src/partitions/mac.c
14604f
+++ b/libblkid/src/partitions/mac.c
14604f
@@ -123,12 +123,12 @@ static int probe_mac_pt(blkid_probe pr,
14604f
 	ssf = block_size / 512;
14604f
 	nblks = be32_to_cpu(p->map_count);
14604f
 
14604f
-	for (i = 1; i <= nblks; ++i) {
14604f
+	for (i = 0; i < nblks; ++i) {
14604f
 		blkid_partition par;
14604f
 		uint32_t start;
14604f
 		uint32_t size;
14604f
 
14604f
-		p = (struct mac_partition *) get_mac_block(pr, block_size, i);
14604f
+		p = (struct mac_partition *) get_mac_block(pr, block_size, i + 1);
14604f
 		if (!p) {
14604f
 			if (errno)
14604f
 				return -errno;
14604f
@@ -141,7 +141,7 @@ static int probe_mac_pt(blkid_probe pr,
14604f
 			DBG(LOWPROBE, ul_debug(
14604f
 				"mac: inconsistent map_count in partition map, "
14604f
 				"entry[0]: %d, entry[%d]: %d",
14604f
-				nblks, i - 1,
14604f
+				nblks, i,
14604f
 				be32_to_cpu(p->map_count)));
14604f
 		}
14604f
 
14604f
-- 
14604f
2.36.1
14604f