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/wall Pull up revsino 1.13 -> 1.14, apoorved by ...



details:   https://anonhg.NetBSD.org/src/rev/fc08fb054801
branches:  netbsd-1-5
changeset: 489605:fc08fb054801
user:      taca <taca%NetBSD.org@localhost>
date:      Sun Oct 01 04:29:18 2000 +0000

description:
Pull up revsino 1.13 -> 1.14, apoorved 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/wall/wall.c |  17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diffs (45 lines):

diff -r 2328fcb47f6f -r fc08fb054801 usr.bin/wall/wall.c
--- a/usr.bin/wall/wall.c       Sat Sep 30 19:57:46 2000 +0000
+++ b/usr.bin/wall/wall.c       Sun Oct 01 04:29:18 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wall.c,v 1.13 2000/04/14 06:11:11 simonb Exp $ */
+/*     $NetBSD: wall.c,v 1.13.4.1 2000/10/01 04:29:18 taca Exp $       */
 
 /*
  * Copyright (c) 1988, 1990, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)wall.c     8.2 (Berkeley) 11/16/93";
 #endif
-__RCSID("$NetBSD: wall.c,v 1.13 2000/04/14 06:11:11 simonb Exp $");
+__RCSID("$NetBSD: wall.c,v 1.13.4.1 2000/10/01 04:29:18 taca Exp $");
 #endif /* not lint */
 
 /*
@@ -138,7 +138,7 @@
        FILE *fp;
        int fd;
        const char *whom;
-       char *p, hostname[MAXHOSTNAMELEN+1], lbuf[100], tmpname[15];
+       char *p, *tty, hostname[MAXHOSTNAMELEN+1], lbuf[100], tmpname[15];
 
        (void)snprintf(tmpname, sizeof tmpname, "%s/wall.XXXXXX", _PATH_TMP);
        if ((fd = mkstemp(tmpname)) == -1 || !(fp = fdopen(fd, "r+")))
@@ -164,8 +164,15 @@
                (void)snprintf(lbuf, sizeof lbuf,
                    "Broadcast Message from %s@%s", whom, hostname);
                (void)fprintf(fp, "%-79.79s\007\007\r\n", lbuf);
-               (void)snprintf(lbuf, sizeof lbuf, "        (%s) at %d:%02d ...",
-                   ttyname(2), lt->tm_hour, lt->tm_min);
+               tty = ttyname(STDERR_FILENO);
+               if (tty == NULL)
+                       (void)snprintf(lbuf, sizeof lbuf,
+                                      "        at %d:%02d ...",
+                                      lt->tm_hour, lt->tm_min);
+               else
+                       (void)snprintf(lbuf, sizeof lbuf,
+                                      "        (%s) at %d:%02d ...",
+                                      tty, lt->tm_hour, lt->tm_min);
                (void)fprintf(fp, "%-79.79s\r\n", lbuf);
        }
        (void)fprintf(fp, "%79s\r\n", " ");



Home | Main Index | Thread Index | Old Index