From 996f35a12d480d934ab6ca9bd931b57fbe2cf38e Mon Sep 17 00:00:00 2001 From: deraadt Date: Fri, 17 Nov 1995 12:39:20 +0000 Subject: [PATCH] handle meta characters; good security idea from freebsd --- usr.bin/write/write.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/usr.bin/write/write.c b/usr.bin/write/write.c index 3dc298f8cd1..00d5e169e2e 100644 --- a/usr.bin/write/write.c +++ b/usr.bin/write/write.c @@ -304,12 +304,17 @@ wr_fputs(s) c = toascii(*s); if (c == '\n') { PUTC('\r'); - PUTC('\n'); } else if (!isprint(c) && !isspace(c) && c != '\007') { - PUTC('^'); - PUTC(c^0x40); /* DEL to ?, others to alpha */ - } else - PUTC(c); + if (c & 0x80) { + PUTC('M'); + PUTC('-'); + c &= ~0x80; + } else { + PUTC('^'); + c &= ~0x40; + } + } + PUTC(c); } return; -- 2.20.1