diff options
author | Sami Kerola | 2018-05-03 23:57:59 +0200 |
---|---|---|
committer | Karel Zak | 2018-05-10 11:29:17 +0200 |
commit | e4077e0e445ddc8d81e4fbab599655bb48ac130a (patch) | |
tree | b6adcfcaae3a2d592a14268c0701b9ae5b844faf /login-utils | |
parent | zramctl: fix truncation warning (diff) | |
download | kernel-qcow2-util-linux-e4077e0e445ddc8d81e4fbab599655bb48ac130a.tar.gz kernel-qcow2-util-linux-e4077e0e445ddc8d81e4fbab599655bb48ac130a.tar.xz kernel-qcow2-util-linux-e4077e0e445ddc8d81e4fbab599655bb48ac130a.zip |
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 <kerolasa@iki.fi>
Diffstat (limited to 'login-utils')
-rw-r--r-- | login-utils/last.c | 2 |
1 files changed, 1 insertions, 1 deletions
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])) |