]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
blkid: improve strcpy() usage [coverity scan]
authorKarel Zak <kzak@redhat.com>
Thu, 16 May 2019 11:56:34 +0000 (13:56 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 16 May 2019 11:56:34 +0000 (13:56 +0200)
The old deprecated list output format ("-o list") copies gettex string
into fixed buffer, that's really bad idea.

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/blkid.c

index 2b13f71c0fb019ac1ebb9465c12087a400016132..f2583d2b883f4270204dec4fc8943e91676fd572 100644 (file)
@@ -225,13 +225,18 @@ static void pretty_print_dev(blkid_dev dev)
        mtpt[0] = 0;
        retval = check_mount_point(devname, &mount_flags, mtpt, sizeof(mtpt));
        if (retval == 0) {
+               const char *msg = NULL;
+
                if (mount_flags & MF_MOUNTED) {
                        if (!mtpt[0])
-                               strcpy(mtpt, _("(mounted, mtpt unknown)"));
+                               msg = _("(mounted, mtpt unknown)");
                } else if (mount_flags & MF_BUSY)
-                       strcpy(mtpt, _("(in use)"));
+                       msg = _("(in use)");
                else
-                       strcpy(mtpt, _("(not mounted)"));
+                       msg = _("(not mounted)");
+
+               if (msg)
+                       xstrncpy(mtpt, msg, sizeof(mtpt));
        }
 
        pretty_print_line(devname, fs_type, label, mtpt, uuid);