]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: fix -E segfault
authorKarel Zak <kzak@redhat.com>
Mon, 15 Jul 2019 10:28:26 +0000 (12:28 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 15 Jul 2019 10:28:26 +0000 (12:28 +0200)
We need to check if referenced wholedisk defines the de-duplication
key...

Addresses: https://github.com/karelzak/util-linux/issues/819
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsblk-devtree.c

index a2aa26aedf33c8bbde2fd4314d0207c40b7eacfb..4d15f70c17d11f6c05f87bc13ec1c35a0dd11cae 100644 (file)
@@ -384,6 +384,7 @@ static int device_dedupkey_is_equal(
                return 0;
        if (strcmp(dev->dedupkey, pattern->dedupkey) == 0) {
                if (!device_is_partition(dev) ||
+                   !dev->wholedisk->dedupkey ||
                     strcmp(dev->dedupkey, dev->wholedisk->dedupkey) != 0) {
                        DBG(DEV, ul_debugobj(dev, "%s: match deduplication pattern", dev->name));
                        return 1;
@@ -458,6 +459,7 @@ int lsblk_devtree_deduplicate_devices(struct lsblk_devtree *tr)
                if (!pattern->dedupkey)
                        continue;
                if (device_is_partition(pattern) &&
+                   pattern->wholedisk->dedupkey &&
                    strcmp(pattern->dedupkey, pattern->wholedisk->dedupkey) == 0)
                        continue;
                if (last && strcmp(pattern->dedupkey, last) == 0)