util-linux/0079-libblkid-limit-amount-of-parsed-partitions.patch

86 lines
2.6 KiB
Diff
Raw Normal View History

From 24f5385f4a54b90f4b7674e23f30567591962bcb Mon Sep 17 00:00:00 2001
From: Samanta Navarro <ferivoz@riseup.net>
Date: Tue, 10 Nov 2020 11:48:04 +0100
Subject: libblkid: limit amount of parsed partitions
The linux kernel does not support more than 256 partitions
(DISK_MAX_PARTS). The atari and mac block devices have no such limits.
Use dos logical partition limit for atari as well (100).
Use the kernel limit for mac (256).
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2060030
Upstream: http://github.com/util-linux/util-linux/commit/c70b4f2a5b99876d230b8f4f413c3bb3ee6647f1
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
---
libblkid/src/partitions/atari.c | 6 +++++-
libblkid/src/partitions/mac.c | 15 +++++++++++----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/libblkid/src/partitions/atari.c b/libblkid/src/partitions/atari.c
index c3f77117a..fdd5498b5 100644
--- a/libblkid/src/partitions/atari.c
+++ b/libblkid/src/partitions/atari.c
@@ -141,12 +141,16 @@ static int parse_extended(blkid_probe pr, blkid_partlist ls,
blkid_parttable tab, struct atari_part_def *part)
{
uint32_t x0start, xstart;
- unsigned i = 0;
+ unsigned ct = 0, i = 0;
int rc;
x0start = xstart = be32_to_cpu(part->start);
while (1) {
struct atari_rootsector *xrs;
+
+ if (++ct > 100)
+ break;
+
xrs = (struct atari_rootsector *) blkid_probe_get_sector(pr, xstart);
if (!xrs) {
if (errno)
diff --git a/libblkid/src/partitions/mac.c b/libblkid/src/partitions/mac.c
index 2be91a620..092d31d32 100644
--- a/libblkid/src/partitions/mac.c
+++ b/libblkid/src/partitions/mac.c
@@ -79,7 +79,7 @@ static int probe_mac_pt(blkid_probe pr,
blkid_partlist ls;
uint16_t block_size;
uint16_t ssf; /* sector size fragment */
- uint32_t nblks, i;
+ uint32_t nblks, nprts, i;
/* The driver descriptor record is always located at physical block 0,
@@ -122,8 +122,15 @@ static int probe_mac_pt(blkid_probe pr,
ssf = block_size / 512;
nblks = be32_to_cpu(p->map_count);
-
- for (i = 0; i < nblks; ++i) {
+ if (nblks > 256) {
+ nprts = 256;
+ DBG(LOWPROBE, ul_debug(
+ "mac: map_count too large, entry[0]: %u, "
+ "enforcing limit of %u", nblks, nprts));
+ } else
+ nprts = nblks;
+
+ for (i = 0; i < nprts; ++i) {
blkid_partition par;
uint32_t start;
uint32_t size;
@@ -140,7 +147,7 @@ static int probe_mac_pt(blkid_probe pr,
if (be32_to_cpu(p->map_count) != nblks) {
DBG(LOWPROBE, ul_debug(
"mac: inconsistent map_count in partition map, "
- "entry[0]: %d, entry[%d]: %d",
+ "entry[0]: %u, entry[%u]: %u",
nblks, i,
be32_to_cpu(p->map_count)));
}
--
2.36.1