From e4077e0e445ddc8d81e4fbab599655bb48ac130a Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Thu, 3 May 2018 22:57:59 +0100 Subject: last: fix false positive compiler warning login-utils/last.c: In function ‘list’: login-utils/last.c:398:36: warning: argument to ‘sizeof’ in ‘strncat’ call is the same expression as the source; did you mean to use the size of the destination? [-Wsizeof-pointer-memaccess] strncat(utline, p->ut_line, sizeof(p->ut_line)); The sizeof(utline) is defined as sizeof(p->ut_line) + 1, so the compiler got that wrong. Lets truncate strncat() otherway around to keep gcc 8.1 happy. Signed-off-by: Sami Kerola --- login-utils/last.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'login-utils') diff --git a/login-utils/last.c b/login-utils/last.c index 80d77d20b..59dfdb2f5 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -395,7 +395,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(p->ut_line)); + strncat(utline, p->ut_line, sizeof(utline) - 1); if (strncmp(utline, "ftp", 3) == 0 && isdigit(utline[3])) utline[3] = 0; if (strncmp(utline, "uucp", 4) == 0 && isdigit(utline[4])) -- cgit v1.2.3-55-g7522