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