]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect-image: also check devtype in device_is_partition()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 21 Feb 2021 02:16:18 +0000 (11:16 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 2 Apr 2021 06:10:09 +0000 (15:10 +0900)
This should be mostly redundant. Just for safety.

src/shared/dissect-image.c

index fb8df16ebc3278b84cf5e58bab386f3881b28858..4a76902b07e3bd6a4f60cecaa975d8e83f1f861f 100644 (file)
@@ -147,15 +147,18 @@ static int device_is_partition(sd_device *d, blkid_partition pp) {
         blkid_loff_t bsize, bstart;
         uint64_t size, start;
         int partno, bpartno, r;
-        const char *ss, *v;
+        const char *v;
 
         assert(d);
         assert(pp);
 
-        r = sd_device_get_subsystem(d, &ss);
+        r = sd_device_get_subsystem(d, &v);
         if (r < 0)
                 return r;
-        if (!streq(ss, "block"))
+        if (!streq(v, "block"))
+                return false;
+
+        if (sd_device_get_devtype(d, &v) < 0 || !streq(v, "partition"))
                 return false;
 
         r = sd_device_get_sysattr_value(d, "partition", &v);