Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Jul 2007 20:45:52 +0200
From:      Niclas Zeising <niclas.zeising@gmail.com>
To:        FreeBSD-gnats-submit@FreeBSD.org,  freebsd-bugs@FreeBSD.org
Subject:   Re: bin/114498: [PATCH] bug in wall makes it skip characters
Message-ID:  <46952560.4030409@gmail.com>
In-Reply-To: <200707111320.l6BDK2RK063280@freefall.freebsd.org>
References:  <200707111320.l6BDK2RK063280@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?46952560.4030409>