[PATCH] wall: wrap message header when it exceeds 79 characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Header truncation started to happen more often after commit
d81c30553f4fb49173d38f69edff4b0b67a18b65 that made the header to be
longer.

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 term-utils/wall.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/term-utils/wall.c b/term-utils/wall.c
index 598e9f2..acada29 100644
--- a/term-utils/wall.c
+++ b/term-utils/wall.c
@@ -202,6 +202,8 @@ static char *makemsg(char *fname, char **mvec, int mvecsz,
 		char *whom, *where, *date;
 		struct passwd *pw;
 		time_t now;
+		ssize_t len;
+		int i;
 
 		if (!(whom = getlogin()) || !*whom)
 			whom = (pw = getpwuid(getuid())) ? pw->pw_name : "???";
@@ -232,7 +234,10 @@ static char *makemsg(char *fname, char **mvec, int mvecsz,
 		fprintf(fp, "\r%*s\r\n", TERM_WIDTH, " ");
 		sprintf(lbuf, _("Broadcast message from %s@%s (%s) (%s):"),
 			      whom, hostname, where, date);
-		fprintf(fp, "%-*.*s\007\007\r\n", TERM_WIDTH, TERM_WIDTH, lbuf);
+		len = strlen(lbuf);
+		for (i = 0; 0 < len; i++)
+			len -= fprintf(fp, "%-*.*s\007\007\r\n", TERM_WIDTH, TERM_WIDTH,
+				       lbuf + (i * TERM_WIDTH)) + 4;
 		free(hostname);
 		free(date);
 	}
-- 
2.0.3

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux