1 Star 0 Fork 25

dashnfschina/util-linux

forked from src-anolis-os/util-linux 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0079-libblkid-limit-amount-of-parsed-partitions.patch 2.64 KB
一键复制 编辑 原始数据 按行查看 历史
renbo02 提交于 2023-01-30 16:56 . update to util-linux-2.32.1-39.el8_7
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dashnfschina/util-linux.git
git@gitee.com:dashnfschina/util-linux.git
dashnfschina
util-linux
util-linux
a8

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385