]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
last: replace strncat() with more robust mem2strcpy()
authorSami Kerola <kerolasa@iki.fi>
Sat, 20 Jul 2019 10:11:01 +0000 (11:11 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 24 Jul 2019 09:11:10 +0000 (11:11 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
login-utils/last.c

index 2f7d9d48f5d0dcb2ea2f8239b73858807866c84e..1b1a741918410e58d6820441e9ed4949a710f5f1 100644 (file)
@@ -394,8 +394,7 @@ static int list(const struct last_control *ctl, struct utmpx *p, time_t logout_t
        /*
         *      uucp and ftp have special-type entries
         */
-       utline[0] = 0;
-       strncat(utline, p->ut_line, sizeof(utline) - 1);
+       mem2strcpy(utline, p->ut_line, sizeof(p->ut_line), sizeof(utline));
        if (strncmp(utline, "ftp", 3) == 0 && isdigit(utline[3]))
                utline[3] = 0;
        if (strncmp(utline, "uucp", 4) == 0 && isdigit(utline[4]))