From b0023655af218d5cd7e168ad0cae6c3139cac427 Mon Sep 17 00:00:00 2001 From: "David E. O'Brien" Date: Tue, 12 Jul 2011 00:31:11 +0000 Subject: [PATCH] If one's message is longer than the buffer size, then we reset 'cnt' at the wrong point and the actual column # get out of sync across the buffer size. --- usr.bin/wall/wall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.bin/wall/wall.c b/usr.bin/wall/wall.c index 5c447493318f..eea253f75097 100644 --- a/usr.bin/wall/wall.c +++ b/usr.bin/wall/wall.c @@ -239,8 +239,9 @@ makemsg(char *fname) err(1, "can't read %s", fname); setegid(egid); } + cnt = 0; while (fgets(lbuf, sizeof(lbuf), stdin)) { - for (cnt = 0, p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) { + for (p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) { if (ch == '\r') { putc('\r', fp); cnt = 0;