diff options
author | Karel Zak | 2006-12-07 00:25:34 +0100 |
---|---|---|
committer | Karel Zak | 2006-12-07 00:25:34 +0100 |
commit | fd6b7a7ffc50400704beb41d5a23af5f9edb1eed (patch) | |
tree | 997c0ca2abc018369babd7da59bcd0afe492068e /login-utils/wall.c | |
parent | Imported from util-linux-2.5 tarball. (diff) | |
download | kernel-qcow2-util-linux-fd6b7a7ffc50400704beb41d5a23af5f9edb1eed.tar.gz kernel-qcow2-util-linux-fd6b7a7ffc50400704beb41d5a23af5f9edb1eed.tar.xz kernel-qcow2-util-linux-fd6b7a7ffc50400704beb41d5a23af5f9edb1eed.zip |
Imported from util-linux-2.7.1 tarball.
Diffstat (limited to 'login-utils/wall.c')
-rw-r--r-- | login-utils/wall.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/login-utils/wall.c b/login-utils/wall.c index 7f3e61235..7957ae299 100644 --- a/login-utils/wall.c +++ b/login-utils/wall.c @@ -127,7 +127,7 @@ usage: continue; #endif strncpy(line, utmp.ut_line, sizeof(utmp.ut_line)); - line[sizeof(utmp.ut_line)] = '\0'; + line[sizeof(utmp.ut_line)-1] = '\0'; if ((p = ttymsg(&iov, 1, line, 60*5)) != NULL) (void)fprintf(stderr, "wall: %s\n", p); } @@ -145,11 +145,11 @@ makemsg(fname) time_t now, time(); FILE *fp; int fd; - char *p, *whom, hostname[MAXHOSTNAMELEN], lbuf[100], tmpname[15]; + char *p, *whom, hostname[MAXHOSTNAMELEN], lbuf[100], tmpname[64]; char *getlogin(), *strcpy(), *ttyname(); - (void)strcpy(tmpname, _PATH_TMP); - (void)strcat(tmpname, "/wall.XXXXXX"); + (void)snprintf(tmpname, sizeof(tmpname), + "%s/wall.XXXXXX", _PATH_TMP); if (!(fd = mkstemp(tmpname)) || !(fp = fdopen(fd, "r+"))) { (void)fprintf(stderr, "wall: can't open temporary file.\n"); exit(1); @@ -171,11 +171,13 @@ makemsg(fname) * in column 80, but that can't be helped. */ (void)fprintf(fp, "\r%79s\r\n", " "); - (void)sprintf(lbuf, "Broadcast Message from %s@%s", - whom, hostname); + (void)snprintf(lbuf, sizeof(lbuf), + "Broadcast Message from %s@%s", + whom, hostname); (void)fprintf(fp, "%-79.79s\007\007\r\n", lbuf); - (void)sprintf(lbuf, " (%s) at %d:%02d ...", ttyname(2), - lt->tm_hour, lt->tm_min); + (void)snprintf(lbuf, sizeof(lbuf), + " (%s) at %d:%02d ...", ttyname(2), + lt->tm_hour, lt->tm_min); (void)fprintf(fp, "%-79.79s\r\n", lbuf); } (void)fprintf(fp, "%79s\r\n", " "); |