From df871b442a50fbf3cc4d8c19deb60a0af5121a8e Mon Sep 17 00:00:00 2001 From: bapt Date: Sat, 8 Aug 2015 23:59:15 +0000 Subject: Remove 5 and 6 bytes sequences which are illegal in UTF-8 space. Per rfc3629 value greater than 0x10ffff should be rejected Suggested by: jilles --- lib/libc/locale/utf8.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/locale/utf8.c b/lib/libc/locale/utf8.c index ce49279..843d59f 100644 --- a/lib/libc/locale/utf8.c +++ b/lib/libc/locale/utf8.c @@ -145,14 +145,6 @@ _UTF8_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n, mask = 0x07; want = 4; lbound = 0x10000; - } else if ((ch & 0xfc) == 0xf8) { - mask = 0x03; - want = 5; - lbound = 0x200000; - } else if ((ch & 0xfe) == 0xfc) { - mask = 0x01; - want = 6; - lbound = 0x4000000; } else { /* * Malformed input; input is not UTF-8. -- cgit v1.1 From 9e0d1c3e199cfcd8480d2e892da387ebb1bbde8b Mon Sep 17 00:00:00 2001 From: bapt Date: Sun, 9 Aug 2015 00:06:56 +0000 Subject: Remove 5 and 6 bytes sequences which are illegal in UTF-8 space. (part2) Per rfc3629 value greater than 0x10ffff should be rejected Suggested by: jilles --- lib/libc/locale/utf8.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/locale/utf8.c b/lib/libc/locale/utf8.c index 843d59f..55e2931 100644 --- a/lib/libc/locale/utf8.c +++ b/lib/libc/locale/utf8.c @@ -320,15 +320,9 @@ _UTF8_wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps) } else if ((wc & ~0xffff) == 0) { lead = 0xe0; len = 3; - } else if ((wc & ~0x1fffff) == 0) { + } else if (wc >= 0 && wc <= 0x10ffff) { lead = 0xf0; len = 4; - } else if ((wc & ~0x3ffffff) == 0) { - lead = 0xf8; - len = 5; - } else if ((wc & ~0x7fffffff) == 0) { - lead = 0xfc; - len = 6; } else { errno = EILSEQ; return ((size_t)-1); -- cgit v1.1 From 0c4c34019a98c0ccc8125e094cab56f2de6705a4 Mon Sep 17 00:00:00 2001 From: bapt Date: Tue, 11 Aug 2015 16:08:10 +0000 Subject: Actually disable the invalid test --- lib/libc/tests/locale/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/tests/locale/Makefile b/lib/libc/tests/locale/Makefile index e4dc553..d9be97c 100644 --- a/lib/libc/tests/locale/Makefile +++ b/lib/libc/tests/locale/Makefile @@ -6,7 +6,7 @@ TESTSDIR= ${TESTSBASE}/lib/libc/locale NETBSD_ATF_TESTS_C= io_test NETBSD_ATF_TESTS_C+= mbrtowc_test -NETBSD_ATF_TESTS_C+= mbstowcs_test +#NETBSD_ATF_TESTS_C+= mbstowcs_test NETBSD_ATF_TESTS_C+= mbsnrtowcs_test NETBSD_ATF_TESTS_C+= mbtowc_test NETBSD_ATF_TESTS_C+= wcscspn_test -- cgit v1.1 From 95ba2a527592a0f1d37f8db28b8809675cc75282 Mon Sep 17 00:00:00 2001 From: jilles Date: Tue, 11 Aug 2015 21:59:36 +0000 Subject: Fix and re-enable UTF-8 tests. --- lib/libc/tests/locale/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/tests/locale/Makefile b/lib/libc/tests/locale/Makefile index d9be97c..e4dc553 100644 --- a/lib/libc/tests/locale/Makefile +++ b/lib/libc/tests/locale/Makefile @@ -6,7 +6,7 @@ TESTSDIR= ${TESTSBASE}/lib/libc/locale NETBSD_ATF_TESTS_C= io_test NETBSD_ATF_TESTS_C+= mbrtowc_test -#NETBSD_ATF_TESTS_C+= mbstowcs_test +NETBSD_ATF_TESTS_C+= mbstowcs_test NETBSD_ATF_TESTS_C+= mbsnrtowcs_test NETBSD_ATF_TESTS_C+= mbtowc_test NETBSD_ATF_TESTS_C+= wcscspn_test -- cgit v1.1 From b9e6da17b9766600007546d2f8e4cf74f35db279 Mon Sep 17 00:00:00 2001 From: araujo Date: Wed, 12 Aug 2015 00:49:20 +0000 Subject: Describe that bcopy(3) is deprecated and marked as LEGACY in POSIX.1-2001 and removed from the specification in POSIX.1-2008. New softwares shall use memcpy(3) or memmove(3). Differential Revision: D3358 Reviewed by: wblock Approved by: rodrigc Sponsored by: gandi.net --- lib/libc/string/bcopy.3 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/string/bcopy.3 b/lib/libc/string/bcopy.3 index 1608fad..ede910b 100644 --- a/lib/libc/string/bcopy.3 +++ b/lib/libc/string/bcopy.3 @@ -31,7 +31,7 @@ .\" @(#)bcopy.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd August 11, 2015 .Dt BCOPY 3 .Os .Sh NAME @@ -57,6 +57,20 @@ The two strings may overlap. If .Fa len is zero, no bytes are copied. +.Pp +This function is deprecated (marked as LEGACY in +POSIX.1-2001): use +.Xr memcpy 3 +or +.Xr memmove 3 +in new programs. +Note that the first two arguments are +interchanged for +.Xr memcpy 3 +and +.Xr memmove 3 . +POSIX.1-2008 removes the specification of +.Fn bcopy . .Sh SEE ALSO .Xr memccpy 3 , .Xr memcpy 3 , -- cgit v1.1