From owner-freebsd-bugs@FreeBSD.ORG Wed Jul 11 13:20:03 2007 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3B8B916A473 for ; Wed, 11 Jul 2007 13:20:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id 1871F13C4BB for ; Wed, 11 Jul 2007 13:20:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l6BDK2rZ063287 for ; Wed, 11 Jul 2007 13:20:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l6BDK2ht063286; Wed, 11 Jul 2007 13:20:02 GMT (envelope-from gnats) Resent-Date: Wed, 11 Jul 2007 13:20:02 GMT Resent-Message-Id: <200707111320.l6BDK2ht063286@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Niclas Zeising Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 585D316A41F for ; Wed, 11 Jul 2007 13:10:05 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [69.147.83.33]) by mx1.freebsd.org (Postfix) with ESMTP id 3CC6013C44B for ; Wed, 11 Jul 2007 13:10:05 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l6BDA4E5079807 for ; Wed, 11 Jul 2007 13:10:05 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id l6BDA456079804; Wed, 11 Jul 2007 13:10:04 GMT (envelope-from nobody) Message-Id: <200707111310.l6BDA456079804@www.freebsd.org> Date: Wed, 11 Jul 2007 13:10:04 GMT From: Niclas Zeising To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.0 Cc: Subject: bin/114498: [PATCH] bug in wall makes it skip characters X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jul 2007 13:20:03 -0000 >Number: 114498 >Category: bin >Synopsis: [PATCH] bug in wall makes it skip characters >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Jul 11 13:20:02 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Niclas Zeising >Release: 7.0-CURRENT >Organization: N/A >Environment: N/A >Description: A bug in the makemsg() function in wall makes it skip one character when wrapping around the line to make a new one. It outputs character ... 78, 79, then cr-lf, then charcater 81, of what's inputed. The same goes for everytime it wraps a line, every 80th char is missing. This is rather annoying since missing characters can give words completely new meanings and wall is used when shutting down etc. >How-To-Repeat: just run wall with a message longer than 80 caracters without a newline and see as one char is missing in the output. >Fix: Attached patch revrites the loop in makemsg() a little so to not skip any characters that shouldn't be skipped. It also raises the warns level to 6 since wall seems to compile at warns 6, at least on i386... That part is not neccecary to include though. Patch attached with submission follows: diff -ur src/src/usr.bin/wall/Makefile src2/src/usr.bin/wall/Makefile --- src/src/usr.bin/wall/Makefile Fri May 27 14:33:28 1994 +++ src2/src/usr.bin/wall/Makefile Tue Jul 10 17:20:55 2007 @@ -2,6 +2,7 @@ PROG= wall SRCS= ttymsg.c wall.c +WARNS= 6 BINGRP= tty BINMODE=2555 diff -ur src/src/usr.bin/wall/wall.c src2/src/usr.bin/wall/wall.c --- src/src/usr.bin/wall/wall.c Tue Feb 21 14:01:00 2006 +++ src2/src/usr.bin/wall/wall.c Wed Jul 11 14:56:14 2007 @@ -193,10 +193,10 @@ exit(1); } -void +static void makemsg(char *fname) { - int cnt; + int cnt = 0; unsigned char ch; struct tm *lt; struct passwd *pw; @@ -251,12 +251,15 @@ err(1, "can't read %s", fname); setegid(egid); } - while (fgets(lbuf, sizeof(lbuf), stdin)) - for (cnt = 0, p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) { - if (ch == '\r') { + while (fgets(lbuf, sizeof(lbuf), stdin)) { + p = lbuf; + /* Thos loop is pending rewrite */ + while ((ch = *p++) != '\0') { + /* for (cnt = 0, p = lbuf; (ch = *p) != '\0'; p++, cnt++) { */ + if (ch == '\r') cnt = 0; - } else if (cnt == 79 || ch == '\n') { - for (; cnt < 79; ++cnt) + else if (ch == '\n') { + for(; cnt < 79; cnt++) putc(' ', fp); putc('\r', fp); putc('\n', fp); @@ -269,13 +272,13 @@ if (ch & 0x80) { ch &= 0x7F; putc('M', fp); - if (++cnt == 79) { + if (++cnt >= 79) { putc('\r', fp); putc('\n', fp); cnt = 0; } putc('-', fp); - if (++cnt == 79) { + if (++cnt >= 79) { putc('\r', fp); putc('\n', fp); cnt = 0; @@ -284,17 +287,28 @@ if (iscntrl(ch)) { ch ^= 040; putc('^', fp); - if (++cnt == 79) { + if (++cnt >= 79) { putc('\r', fp); putc('\n', fp); cnt = 0; } } putc(ch, fp); + if (++cnt >= 79) { + putc('\r', fp); + putc('\n', fp); + cnt = 0; + } } else { putc(ch, fp); + if (++cnt >= 79) { + putc('\r', fp); + putc('\n', fp); + cnt = 0; + } } } + } (void)fprintf(fp, "%79s\r\n", " "); rewind(fp); >Release-Note: >Audit-Trail: >Unformatted: