From: Ralph Corderoy Date: Sun, 1 Jul 2018 08:32:28 +0000 (+0100) Subject: rcvtty.c: Use struct utmpx's ut_line[], not a copy. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/6567362ad831e08b8314297cf12bb732e8eb20c7 rcvtty.c: Use struct utmpx's ut_line[], not a copy. Silences gcc 8.1.1's warning that strncpy(3)'s length is the sizeof of the source, not the destination, by removing the strncpy and passing the source to alert() where it's only read, not written. --- diff --git a/uip/rcvtty.c b/uip/rcvtty.c index 4098d709..73440fb0 100644 --- a/uip/rcvtty.c +++ b/uip/rcvtty.c @@ -82,7 +82,7 @@ int main (int argc, char **argv) { int md, vecp = 0; - char *cp, *user, buf[BUFSIZ], tty[BUFSIZ]; + char *cp, *user, buf[BUFSIZ]; char **argp, **arguments, *vec[MAXARGS]; struct utmpx *utp; @@ -160,13 +160,11 @@ main (int argc, char **argv) if (utp->ut_type == USER_PROCESS && utp->ut_user[0] != 0 && utp->ut_line[0] != 0 && strncmp (user, utp->ut_user, sizeof(utp->ut_user)) == 0) { - strncpy (tty, utp->ut_line, sizeof(utp->ut_line)); - alert (tty, md); + alert(utp->ut_line, md); } } endutxent(); #else - NMH_UNUSED (tty); NMH_UNUSED (utp); #endif /* HAVE_GETUTXENT */