From owner-freebsd-bugs@FreeBSD.ORG Wed Jul 11 20:00:20 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 B591916A469 for ; Wed, 11 Jul 2007 20:00:20 +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 976CC13C465 for ; Wed, 11 Jul 2007 20:00:20 +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 l6BK0KN3012827 for ; Wed, 11 Jul 2007 20:00:20 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l6BK0Kmk012826; Wed, 11 Jul 2007 20:00:20 GMT (envelope-from gnats) Date: Wed, 11 Jul 2007 20:00:20 GMT Message-Id: <200707112000.l6BK0Kmk012826@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Niclas Zeising Cc: Subject: Re: bin/114498: [PATCH] bug in wall makes it skip characters X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Niclas Zeising List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jul 2007 20:00:20 -0000 The following reply was made to PR bin/114498; it has been noted by GNATS. From: Niclas Zeising To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org Cc: Subject: Re: bin/114498: [PATCH] bug in wall makes it skip characters Date: Wed, 11 Jul 2007 20:45:52 +0200 This is a multi-part message in MIME format. --------------080209060103050402050605 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit FreeBSD-gnats-submit@FreeBSD.org wrote: > Thank you very much for your problem report. > It has the internal identification `bin/114498'. > The individual assigned to look at your > report is: freebsd-bugs. > > You can access the state of your problem report at any time > via this link: > > http://www.freebsd.org/cgi/query-pr.cgi?pr=114498 > >> Category: bin >> Responsible: freebsd-bugs >> Synopsis: [PATCH] bug in wall makes it skip characters >> Arrival-Date: Wed Jul 11 13:20:02 GMT 2007 > After reviewing the patch i noticed I had forgotten to remove two comments I kept during the rewrite, so I've made a new patch. The patch is only for wall.c, Makefile is fine as it is in the patch. Regards! //Niclas --------------080209060103050402050605 Content-Type: text/plain; name="wall.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="wall.c.diff" --- src/usr.bin/wall/wall.c.orig 2007-07-11 20:40:25.000000000 +0200 +++ src/usr.bin/wall/wall.c 2007-07-11 17:33:23.000000000 +0200 @@ -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,14 @@ 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; + while ((ch = *p++) != '\0') { + 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 +271,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 +286,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); --------------080209060103050402050605--