handle meta characters; good security idea from freebsd
authorderaadt <deraadt@openbsd.org>
Fri, 17 Nov 1995 12:39:20 +0000 (12:39 +0000)
committerderaadt <deraadt@openbsd.org>
Fri, 17 Nov 1995 12:39:20 +0000 (12:39 +0000)
usr.bin/write/write.c

index 3dc298f..00d5e16 100644 (file)
@@ -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;