]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/ismounted: more robust buffer usage [clang-analyze]
authorKarel Zak <kzak@redhat.com>
Tue, 1 Jul 2014 11:51:32 +0000 (13:51 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 1 Jul 2014 11:51:32 +0000 (13:51 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/ismounted.c

index 2463f3356a8018ec6ce7745f73af30fc63cb1783..8a882b27e665144b378761fa5c806222b04a34cd 100644 (file)
@@ -317,7 +317,8 @@ int check_mount_point(const char *device, int *mount_flags,
 
        if (is_swap_device(device)) {
                *mount_flags = MF_MOUNTED | MF_SWAP;
-               strncpy(mtpt, "<swap>", mtlen);
+               if (mtpt && mtlen)
+                       strncpy(mtpt, "<swap>", mtlen);
        } else {
 #ifdef HAVE_MNTENT_H
                retval = check_mntent(device, mount_flags, mtpt, mtlen);