Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/usr.bin/rwall Pullup revision 1.11 -> 1.12, approved by...



details:   https://anonhg.NetBSD.org/src/rev/5d55d86b0285
branches:  netbsd-1-5
changeset: 489606:5d55d86b0285
user:      taca <taca%NetBSD.org@localhost>
date:      Sun Oct 01 04:32:31 2000 +0000

description:
Pullup revision 1.11 -> 1.12, approved by jhawk:

> - Check return value of ttyname(3) and prevent to pass NULL pointer for
>   "%s" in printf style format string.
> - Use STDERR_FILENO as paramter for ttyname(3).

diffstat:

 usr.bin/rwall/rwall.c |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (43 lines):

diff -r fc08fb054801 -r 5d55d86b0285 usr.bin/rwall/rwall.c
--- a/usr.bin/rwall/rwall.c     Sun Oct 01 04:29:18 2000 +0000
+++ b/usr.bin/rwall/rwall.c     Sun Oct 01 04:32:31 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rwall.c,v 1.11 2000/06/14 06:49:22 cgd Exp $ */
+/* $NetBSD: rwall.c,v 1.11.2.1 2000/10/01 04:32:31 taca Exp $ */
 
 /*
  * Copyright (c) 1993 Christopher G. Demetriou
@@ -44,7 +44,7 @@
 #if 0
 static char sccsid[] = "from: @(#)wall.c       5.14 (Berkeley) 3/2/91";
 #else
-__RCSID("$NetBSD: rwall.c,v 1.11 2000/06/14 06:49:22 cgd Exp $");
+__RCSID("$NetBSD: rwall.c,v 1.11.2.1 2000/10/01 04:32:31 taca Exp $");
 #endif
 #endif /* not lint */
 
@@ -129,7 +129,7 @@
        FILE *fp;
        int fd;
        const char *whom;
-       char hostname[MAXHOSTNAMELEN + 1], lbuf[100], tmpname[32];
+       char *tty, hostname[MAXHOSTNAMELEN + 1], lbuf[100], tmpname[32];
 
        (void)strcpy(tmpname, _PATH_TMP);
        (void)strcat(tmpname, "/wall.XXXXXX");
@@ -153,8 +153,13 @@
         */
        (void)fprintf(fp, "Remote Broadcast Message from %s@%s\n",
            whom, hostname);
-       (void)fprintf(fp, "        (%s) at %d:%02d ...\n", ttyname(2),
-           lt->tm_hour, lt->tm_min);
+       tty = ttyname(STDERR_FILENO);
+       if (tty == NULL)
+               (void)fprintf(fp, "        at %d:%02d ...\n",
+                             lt->tm_hour, lt->tm_min);
+       else
+               (void)fprintf(fp, "        (%s) at %d:%02d ...\n", tty,
+                             lt->tm_hour, lt->tm_min);
 
        putc('\n', fp);
 



Home | Main Index | Thread Index | Old Index