dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

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

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