diff options
author | 2010-08-24 23:49:06 +0000 | |
---|---|---|
committer | 2010-08-24 23:49:06 +0000 | |
commit | 24f1563c489f5c5401f43cd512eadd73f9a3dcc9 (patch) | |
tree | f3dc40583f554aa0d634e18f6482027da276cac2 /lib/libc/gen/vis.c | |
parent | spaces (diff) | |
download | wireguard-openbsd-24f1563c489f5c5401f43cd512eadd73f9a3dcc9.tar.xz wireguard-openbsd-24f1563c489f5c5401f43cd512eadd73f9a3dcc9.zip |
backout VIS_HEX. guenther@ points out that the C89 \xff encoding
idiotically accepts more then two hex digits following the \x, even
on platforms where a char has 8 bits. It is therefore dangerous to have
an almost-bit-not-quite compatible format in vis(3).
The VIS_ALL (encode all characters) option introduced in the same commit
remains.
Diffstat (limited to 'lib/libc/gen/vis.c')
-rw-r--r-- | lib/libc/gen/vis.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/lib/libc/gen/vis.c b/lib/libc/gen/vis.c index 51407e6a7da..83227d96705 100644 --- a/lib/libc/gen/vis.c +++ b/lib/libc/gen/vis.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vis.c,v 1.20 2010/08/21 18:59:15 djm Exp $ */ +/* $OpenBSD: vis.c,v 1.21 2010/08/24 23:49:06 djm Exp $ */ /*- * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -46,8 +46,6 @@ (c) == '\007' || (c) == '\r' || \ isgraph((u_char)(c))))) -static const char hexdigits[] = "0123456789abcdef"; - /* * vis - visually encode characters */ @@ -106,19 +104,12 @@ vis(char *dst, int c, int flag, int nextc) goto done; } } - if (((c & 0177) == ' ') || (flag & (VIS_OCTAL|VIS_HEX)) || + if (((c & 0177) == ' ') || (flag & VIS_OCTAL) || ((flag & VIS_GLOB) && (c == '*' || c == '?' || c == '[' || c == '#'))) { - if ((flag & VIS_HEX) != 0) { - *dst++ = '\\'; - *dst++ = 'x'; - *dst++ = hexdigits[((u_char)c >> 4 & 0xf)]; - *dst++ = hexdigits[((u_char)c & 0xf)]; - } else { - *dst++ = '\\'; - *dst++ = ((u_char)c >> 6 & 07) + '0'; - *dst++ = ((u_char)c >> 3 & 07) + '0'; - *dst++ = ((u_char)c & 07) + '0'; - } + *dst++ = '\\'; + *dst++ = ((u_char)c >> 6 & 07) + '0'; + *dst++ = ((u_char)c >> 3 & 07) + '0'; + *dst++ = ((u_char)c & 07) + '0'; goto done; } if ((flag & VIS_NOSLASH) == 0) |