dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

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

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