summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2018-09-30 12:44:22 +0000
committerschwarze <schwarze@openbsd.org>2018-09-30 12:44:22 +0000
commitfdee8386be8e5a0295ae47fcf2e40b04398df1d4 (patch)
tree79d057b97c6fbdc7a90293b412a03d24ec9c9a0c
parentfix the rest of the bug mitigated in the previous commit: (diff)
downloadwireguard-openbsd-fdee8386be8e5a0295ae47fcf2e40b04398df1d4.tar.xz
wireguard-openbsd-fdee8386be8e5a0295ae47fcf2e40b04398df1d4.zip
For -w output in -m mode, tweak the handling of bytes that do not
form valid UTF-8: treat them as "not a whitespace character" and hence "not a word boundary" in the same way as non-printable characters and NUL bytes. OK millert@
-rw-r--r--regress/usr.bin/wc/wc.sh2
-rw-r--r--usr.bin/wc/wc.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/regress/usr.bin/wc/wc.sh b/regress/usr.bin/wc/wc.sh
index 1e52c33d73a..1cb43ccb5c7 100644
--- a/regress/usr.bin/wc/wc.sh
+++ b/regress/usr.bin/wc/wc.sh
@@ -65,7 +65,7 @@ test_wc "a\0354\0277\0277b\n" " 1 1 4" \
" 1 1 6"
# invalid bytes
-test_wc "a\0377\0277c\n" " 1 2 5" " 1 1 5"
+test_wc "a\0377\0277c\n" " 1 1 5"
# edge cases
test_wc "" " 0 0 0"
diff --git a/usr.bin/wc/wc.c b/usr.bin/wc/wc.c
index 237b03385c5..db3a89ea0af 100644
--- a/usr.bin/wc/wc.c
+++ b/usr.bin/wc/wc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wc.c,v 1.24 2018/09/30 12:35:40 schwarze Exp $ */
+/* $OpenBSD: wc.c,v 1.25 2018/09/30 12:44:22 schwarze Exp $ */
/*
* Copyright (c) 1980, 1987, 1991, 1993
@@ -217,7 +217,7 @@ cnt(char *file)
mbtowc(NULL, NULL,
MB_CUR_MAX);
len = 1;
- wc = L' ';
+ wc = L'?';
} else if (len == 0)
len = 1;
if (iswspace(wc)) {