]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
Fix off by one when checking "/dev/mapper/" path
authorDisconnect3d <dominik.b.czarnota@gmail.com>
Mon, 13 Apr 2020 14:14:10 +0000 (16:14 +0200)
committerGitHub <noreply@github.com>
Mon, 13 Apr 2020 14:14:10 +0000 (16:14 +0200)
This PR fixes an off by one in `strncmp(dev->bid_name, "/dev/mapper/", 11)` check. The `"/dev/mapper/"` string literal has a length of 12 and without this fix paths like `"/dev/mapperSOMETHING"` would also be accepted.

libblkid/src/devname.c

index 014b3f490bf948a563b1931eb429f80a2fb9d794..bb0211da403b23f554d55a556d6dd42693d89eba 100644 (file)
@@ -258,7 +258,7 @@ set_pri:
        if (dev) {
                if (pri)
                        dev->bid_pri = pri;
-               else if (!strncmp(dev->bid_name, "/dev/mapper/", 11)) {
+               else if (!strncmp(dev->bid_name, "/dev/mapper/", 12)) {
                        dev->bid_pri = BLKID_PRI_DM;
                        if (is_dm_leaf(ptname))
                                dev->bid_pri += 5;