]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid:(dos) make subtypes probing more robust
authorKarel Zak <kzak@redhat.com>
Tue, 27 Feb 2018 09:36:40 +0000 (10:36 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 27 Feb 2018 09:36:40 +0000 (10:36 +0100)
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 <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/partitions/dos.c

index 1db238781013d0a14cee18d87665f6275a58f9cc..659ca9a1669a83680dd5c0ca88f01fd796cf4a45 100644 (file)
@@ -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;