]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
vipw: use xstrncpy()
authorKarel Zak <kzak@redhat.com>
Mon, 20 May 2019 10:57:39 +0000 (12:57 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 20 May 2019 10:57:39 +0000 (12:57 +0200)
It's already used by vipw, so use it everywhere.

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

index 2b35036e618e5de152043f2175f20e5d9cad9b6c..a071b639dd03e1926c07405941de64479bd62a8e 100644 (file)
@@ -335,7 +335,7 @@ int main(int argc, char *argv[])
                xstrncpy(orig_file, PASSWD_FILE, sizeof(orig_file));
        }
 
-       while ((c = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1)
+       while ((c = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1) {
                switch (c) {
                case 'V':
                        print_version(EXIT_SUCCESS);
@@ -344,14 +344,14 @@ int main(int argc, char *argv[])
                default:
                        errtryhelp(EXIT_FAILURE);
                }
+       }
 
        edit_file(0);
 
-       if (program == VIGR) {
-               strncpy(orig_file, SGROUP_FILE, FILENAMELEN - 1);
-       } else {
-               strncpy(orig_file, SHADOW_FILE, FILENAMELEN - 1);
-       }
+       if (program == VIGR)
+               xstrncpy(orig_file, SGROUP_FILE, sizeof(orig_file));
+       else
+               xstrncpy(orig_file, SHADOW_FILE, sizeof(orig_file));
 
        if (access(orig_file, F_OK) == 0) {
                char response[80];