From 0e06893f6afcd14462fb3d4710139d7828c832fb Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 27 Feb 2018 10:36:40 +0100 Subject: libblkid:(dos) make subtypes probing more robust The current code mix partitions as defined on disk with partitions from partlist (as recognized by libblkid). It seems better to follow partlist only. Reported-by: Vaclav Dolezal Signed-off-by: Karel Zak --- libblkid/src/partitions/dos.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'libblkid') diff --git a/libblkid/src/partitions/dos.c b/libblkid/src/partitions/dos.c index 1db238781..659ca9a16 100644 --- a/libblkid/src/partitions/dos.c +++ b/libblkid/src/partitions/dos.c @@ -307,20 +307,31 @@ static int probe_dos_pt(blkid_probe pr, /* Parse subtypes (nested partitions) on large disks */ if (!blkid_probe_is_tiny(pr)) { - for (p = p0, i = 0; i < 4; i++, p++) { + int nparts = blkid_partlist_numof_partitions(ls); + + DBG(LOWPROBE, ul_debug("checking for subtypes")); + + for (i = 0; i < nparts; i++) { size_t n; - int rc; + int type; + blkid_partition pa = blkid_partlist_get_partition(ls, i); - if (!dos_partition_get_size(p) || is_extended(p)) + if (pa == NULL + || blkid_partition_get_size(pa) == 0 + || blkid_partition_is_extended(pa) + || blkid_partition_is_logical(pa)) continue; + type = blkid_partition_get_type(pa); + for (n = 0; n < ARRAY_SIZE(dos_nested); n++) { - if (dos_nested[n].type != p->sys_ind) + int rc; + + if (dos_nested[n].type != type) continue; - rc = blkid_partitions_do_subprobe(pr, - blkid_partlist_get_partition(ls, i), - dos_nested[n].id); + rc = blkid_partitions_do_subprobe(pr, pa, + dos_nested[n].id); if (rc < 0) return rc; break; -- cgit v1.2.3-55-g7522