]> diplodocus.org Git - nmh/commitdiff
rcvtty.c: Use struct utmpx's ut_line[], not a copy.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sun, 1 Jul 2018 08:32:28 +0000 (09:32 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 1 Jul 2018 10:12:42 +0000 (11:12 +0100)
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.

uip/rcvtty.c

index 4098d70..73440fb 100644 (file)
@@ -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 */