|
|
531551 |
From 8125a64ff9e98d09c659dbd5adbca521d63a268b Mon Sep 17 00:00:00 2001
|
|
|
531551 |
From: Karel Zak <kzak@redhat.com>
|
|
|
531551 |
Date: Thu, 7 Jul 2016 14:22:41 +0200
|
|
|
531551 |
Subject: [PATCH 86/86] libblkid: avoid recursion in EBR
|
|
|
531551 |
|
|
|
531551 |
Upstream: http://github.com/karelzak/util-linux/commit/7164a1c34d18831ac61c6744ad14ce916d389b3f
|
|
|
531551 |
Upstream: http://github.com/karelzak/util-linux/commit/50d1594c2e6142a3b51d2143c74027480df082e0
|
|
|
531551 |
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1349536
|
|
|
531551 |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
531551 |
---
|
|
|
531551 |
libblkid/src/partitions/dos.c | 21 +++++++++++++++++++--
|
|
|
531551 |
libblkid/src/partitions/partitions.c | 14 ++++++++++++++
|
|
|
531551 |
libblkid/src/partitions/partitions.h | 2 ++
|
|
|
531551 |
3 files changed, 35 insertions(+), 2 deletions(-)
|
|
|
531551 |
|
|
|
531551 |
diff --git a/libblkid/src/partitions/dos.c b/libblkid/src/partitions/dos.c
|
|
|
531551 |
index 2d4a537..563fe9a 100644
|
|
|
531551 |
--- a/libblkid/src/partitions/dos.c
|
|
|
531551 |
+++ b/libblkid/src/partitions/dos.c
|
|
|
531551 |
@@ -48,6 +48,12 @@ static int parse_dos_extended(blkid_probe pr, blkid_parttable tab,
|
|
|
531551 |
int ct_nodata = 0; /* count ext.partitions without data partitions */
|
|
|
531551 |
int i;
|
|
|
531551 |
|
|
|
531551 |
+ DBG(LOWPROBE, blkid_debug("parse EBR [start=%d, size=%d]", ex_start/ssf, ex_size/ssf));
|
|
|
531551 |
+ if (ex_start == 0) {
|
|
|
531551 |
+ DBG(LOWPROBE, blkid_debug("Bad offset in primary extended partition -- ignore"));
|
|
|
531551 |
+ return 0;
|
|
|
531551 |
+ }
|
|
|
531551 |
+
|
|
|
531551 |
while (1) {
|
|
|
531551 |
struct dos_partition *p, *p0;
|
|
|
531551 |
uint32_t start, size;
|
|
|
531551 |
@@ -100,6 +106,13 @@ static int parse_dos_extended(blkid_probe pr, blkid_parttable tab,
|
|
|
531551 |
continue;
|
|
|
531551 |
}
|
|
|
531551 |
|
|
|
531551 |
+ /* Avoid recursive non-empty links, see ct_nodata counter */
|
|
|
531551 |
+ if (blkid_partlist_get_partition_by_start(ls, abs_start)) {
|
|
|
531551 |
+ DBG(LOWPROBE, blkid_debug("#%d: EBR duplicate data partition [abs start=%u] -- ignore",
|
|
|
531551 |
+ i + 1, abs_start));
|
|
|
531551 |
+ continue;
|
|
|
531551 |
+ }
|
|
|
531551 |
+
|
|
|
531551 |
par = blkid_partlist_add_partition(ls, tab, abs_start, size);
|
|
|
531551 |
if (!par)
|
|
|
531551 |
return -ENOMEM;
|
|
|
531551 |
@@ -116,8 +129,12 @@ static int parse_dos_extended(blkid_probe pr, blkid_parttable tab,
|
|
|
531551 |
start = dos_partition_start(p) * ssf;
|
|
|
531551 |
size = dos_partition_size(p) * ssf;
|
|
|
531551 |
|
|
|
531551 |
- if (size && is_extended(p))
|
|
|
531551 |
- break;
|
|
|
531551 |
+ if (size && is_extended(p)) {
|
|
|
531551 |
+ if (start == 0)
|
|
|
531551 |
+ DBG(LOWPROBE, blkid_debug("#%d: EBR link offset is zero -- ignore", i + 1));
|
|
|
531551 |
+ else
|
|
|
531551 |
+ break;
|
|
|
531551 |
+ }
|
|
|
531551 |
}
|
|
|
531551 |
if (i == 4)
|
|
|
531551 |
goto leave;
|
|
|
531551 |
diff --git a/libblkid/src/partitions/partitions.c b/libblkid/src/partitions/partitions.c
|
|
|
531551 |
index 752fc95..9d846ff 100644
|
|
|
531551 |
--- a/libblkid/src/partitions/partitions.c
|
|
|
531551 |
+++ b/libblkid/src/partitions/partitions.c
|
|
|
531551 |
@@ -928,6 +928,20 @@ blkid_partition blkid_partlist_get_partition(blkid_partlist ls, int n)
|
|
|
531551 |
return &ls->parts[n];
|
|
|
531551 |
}
|
|
|
531551 |
|
|
|
531551 |
+blkid_partition blkid_partlist_get_partition_by_start(blkid_partlist ls, uint64_t start)
|
|
|
531551 |
+{
|
|
|
531551 |
+ int i, nparts;
|
|
|
531551 |
+ blkid_partition par;
|
|
|
531551 |
+
|
|
|
531551 |
+ nparts = blkid_partlist_numof_partitions(ls);
|
|
|
531551 |
+ for (i = 0; i < nparts; i++) {
|
|
|
531551 |
+ par = blkid_partlist_get_partition(ls, i);
|
|
|
531551 |
+ if ((uint64_t) blkid_partition_get_start(par) == start)
|
|
|
531551 |
+ return par;
|
|
|
531551 |
+ }
|
|
|
531551 |
+ return NULL;
|
|
|
531551 |
+}
|
|
|
531551 |
+
|
|
|
531551 |
/**
|
|
|
531551 |
* blkid_partlist_devno_to_partition:
|
|
|
531551 |
* @ls: partitions list
|
|
|
531551 |
diff --git a/libblkid/src/partitions/partitions.h b/libblkid/src/partitions/partitions.h
|
|
|
531551 |
index 61763bf..4e99e2a 100644
|
|
|
531551 |
--- a/libblkid/src/partitions/partitions.h
|
|
|
531551 |
+++ b/libblkid/src/partitions/partitions.h
|
|
|
531551 |
@@ -20,6 +20,8 @@ extern int blkid_partlist_increment_partno(blkid_partlist ls);
|
|
|
531551 |
|
|
|
531551 |
extern blkid_partition blkid_partlist_get_parent(blkid_partlist ls);
|
|
|
531551 |
|
|
|
531551 |
+extern blkid_partition blkid_partlist_get_partition_by_start(blkid_partlist ls, uint64_t start);
|
|
|
531551 |
+
|
|
|
531551 |
extern int blkid_partitions_do_subprobe(blkid_probe pr,
|
|
|
531551 |
blkid_partition parent, const struct blkid_idinfo *id);
|
|
|
531551 |
|
|
|
531551 |
--
|
|
|
531551 |
2.7.4
|
|
|
531551 |
|