summaryrefslogtreecommitdiff
path: root/libexec/comsat
diff options
context:
space:
mode:
authoratatat <atatat@NetBSD.org>2001-03-14 04:39:42 +0000
committeratatat <atatat@NetBSD.org>2001-03-14 04:39:42 +0000
commit32af82236c1244d214cebb341ef3a0eb9a5cb89e (patch)
tree1a9080307ee26898e7db70641035ea68125eb4c6 /libexec/comsat
parent39dcc600322c9d85598c692e9334b99feddf262e (diff)
Fix output to a tty that is missing ONLCR (eg emacs, vi, mutt,
etc.). This became broken when strvis(3) started being used instead of simply scanning for "bad" characters.
Diffstat (limited to 'libexec/comsat')
-rw-r--r--libexec/comsat/comsat.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libexec/comsat/comsat.c b/libexec/comsat/comsat.c
index 9a0eb208324..59431c24420 100644
--- a/libexec/comsat/comsat.c
+++ b/libexec/comsat/comsat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: comsat.c,v 1.19 2001/02/19 22:46:13 cgd Exp $ */
+/* $NetBSD: comsat.c,v 1.20 2001/03/14 04:39:42 atatat Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
#if 0
static char sccsid[] = "from: @(#)comsat.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: comsat.c,v 1.19 2001/02/19 22:46:13 cgd Exp $");
+__RCSID("$NetBSD: comsat.c,v 1.20 2001/03/14 04:39:42 atatat Exp $");
#endif
#endif /* not lint */
@@ -261,7 +261,7 @@ jkfprintf(FILE *tp, char name[], off_t offset)
{
FILE *fi;
int linecnt, charcnt, inheader;
- char line[BUFSIZ], visline[BUFSIZ*4];
+ char line[BUFSIZ], visline[BUFSIZ*4], *nl;
if ((fi = fopen(name, "r")) == NULL)
return;
@@ -276,6 +276,7 @@ jkfprintf(FILE *tp, char name[], off_t offset)
charcnt = 560;
inheader = 1;
while (fgets(line, sizeof(line), fi) != NULL) {
+ line[sizeof(line) - 1] = '\0';
if (inheader) {
if (line[0] == '\n') {
inheader = 0;
@@ -291,9 +292,12 @@ jkfprintf(FILE *tp, char name[], off_t offset)
(void)fclose(fi);
return;
}
+ if ((nl = strchr(line, '\n')) != NULL)
+ *nl = '\0';
/* strip weird stuff so can't trojan horse stupid terminals */
(void)strvis(visline, line, VIS_CSTYLE);
- fputs(visline, tp);
+ (void)fputs(visline, tp);
+ (void)fputs(cr, tp);
--linecnt;
}
(void)fprintf(tp, "----%s\n", cr);