control_char() for ASCII needs to include both genuine control
authornicm <nicm@openbsd.org>
Thu, 20 Apr 2017 21:23:16 +0000 (21:23 +0000)
committernicm <nicm@openbsd.org>
Thu, 20 Apr 2017 21:23:16 +0000 (21:23 +0000)
characters and top-bit-set nonprintable characters (so both iscntrl()
and !isprint()), fixes behaviour broken in r1.15/r1.16, noticed by
deraadt@.

ok deraadt tedu

usr.bin/less/charset.c

index 73c7a17..4c8db50 100644 (file)
@@ -164,7 +164,9 @@ int
 control_char(LWCHAR c)
 {
        c &= 0377;
-       return (iscntrl((unsigned char)c));
+       if (utf_mode)
+               return (iscntrl((unsigned char)c));
+       return (iscntrl((unsigned char)c) || !isprint((unsigned char)c));
 }
 
 /*