summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Janzen <pjanzen@cvs.openbsd.org>2003-05-12 20:53:23 +0000
committerPaul Janzen <pjanzen@cvs.openbsd.org>2003-05-12 20:53:23 +0000
commitdfcf2496456044d062294971de34babb89c824b2 (patch)
tree4c1e674f56a59da6e108e1f6191d8ac1e4158efa
parentc5edf782b824e2f59d4df56f24f1b9bc37321540 (diff)
Do vis()-cleaning when displaying the print queue.
ok deraadt@, ian@
-rw-r--r--usr.sbin/lpr/common_source/displayq.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c
index 97c6425314f..2c0541b0d25 100644
--- a/usr.sbin/lpr/common_source/displayq.c
+++ b/usr.sbin/lpr/common_source/displayq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: displayq.c,v 1.23 2003/04/05 10:42:54 avsm Exp $ */
+/* $OpenBSD: displayq.c,v 1.24 2003/05/12 20:53:22 pjanzen Exp $ */
/* $NetBSD: displayq.c,v 1.21 2001/08/30 00:51:50 itojun Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static const char sccsid[] = "@(#)displayq.c 8.4 (Berkeley) 4/28/95";
#else
-static const char rcsid[] = "$OpenBSD: displayq.c,v 1.23 2003/04/05 10:42:54 avsm Exp $";
+static const char rcsid[] = "$OpenBSD: displayq.c,v 1.24 2003/05/12 20:53:22 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -56,6 +56,7 @@ static const char rcsid[] = "$OpenBSD: displayq.c,v 1.23 2003/04/05 10:42:54 avs
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <vis.h>
#include "lp.h"
#include "lp.local.h"
@@ -282,6 +283,7 @@ displayq(int format)
}
else {
struct sigaction osa, nsa;
+ char *visline;
i = strlen(line);
if (write(fd, line, i) != i)
@@ -292,12 +294,16 @@ displayq(int format)
nsa.sa_flags = 0;
(void)sigaction(SIGALRM, &nsa, &osa);
alarm(wait_time);
+ if ((visline = (char *)malloc(4 * sizeof(line) + 1)) == NULL)
+ fatal("Out of memory");
while ((i = read(fd, line, sizeof(line))) > 0) {
- (void)fwrite(line, 1, i, stdout);
+ i = strvisx(visline, line, i, VIS_SAFE|VIS_NOSLASH);
+ (void)fwrite(visline, 1, i, stdout);
alarm(wait_time);
}
alarm(0);
(void)sigaction(SIGALRM, &osa, NULL);
+ free(visline);
(void)close(fd);
}
}