]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/path: use xstrncpy()
authorKarel Zak <kzak@redhat.com>
Mon, 20 May 2019 10:57:16 +0000 (12:57 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 20 May 2019 10:57:16 +0000 (12:57 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/path.c

index 05b608e573b48ba47cd1d64c0774fdbd8ffb64b9..f7fd19592447b3e929751f6c7447e2cdb673b2cc 100644 (file)
@@ -25,6 +25,7 @@
 #include "all-io.h"
 #include "path.h"
 #include "debug.h"
+#include "strutils.h"
 
 /*
  * Debug stuff (based on include/debug.h)
@@ -279,8 +280,7 @@ char *ul_path_get_abspath(struct path_cxt *pc, char *buf, size_t bufsz, const ch
 
                if (!tmp)
                        return NULL;
-               strncpy(buf, tmp, bufsz);
-               buf[bufsz - 1] = '\0';
+               xstrncpy(buf, tmp, bufsz);
        }
 
        return buf;