]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/canonicalize: verify DM paths [coverity scan]
authorKarel Zak <kzak@redhat.com>
Tue, 14 May 2019 13:47:02 +0000 (15:47 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 14 May 2019 13:47:02 +0000 (15:47 +0200)
Now the code only checks that /sys/.../dm/name exists, but never
verify the device node in /dev (because path prefix is never NULL).

The prefix is used to redirect hardcoded paths to /sys dumps (e.g.
lsblk regression tests, etc.)

This bug has been introduced in v2.33. Fortunately, it's probably no
big issue as /dev is always in sync with /sys (thanks to udevd).

Signed-off-by: Karel Zak <kzak@redhat.com>
lib/canonicalize.c

index fe104953deb5b2062a43ff529056edfbc655d828..e8d170c867127498744e776cb33c0cf07ca51287 100644 (file)
@@ -47,7 +47,7 @@ char *__canonicalize_dm_name(const char *prefix, const char *ptname)
                name[sz - 1] = '\0';
                snprintf(path, sizeof(path), _PATH_DEV_MAPPER "/%s", name);
 
-               if (prefix || access(path, F_OK) == 0)
+               if ((prefix && *prefix) || access(path, F_OK) == 0)
                        res = strdup(path);
        }
        fclose(f);