Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177459845
D43262.1794464369.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D43262.1794464369.diff
View Options
diff --git a/lib/libc/locale/euc.c b/lib/libc/locale/euc.c
--- a/lib/libc/locale/euc.c
+++ b/lib/libc/locale/euc.c
@@ -426,7 +426,7 @@
/* This first check excludes CS1, which is implicitly valid. */
if ((wc < 0xa100) || (wc > 0xffff)) {
/* Check for valid CS2 or CS3 */
- nm = (wc >> ((len - 1) * 8));
+ nm = (wc >> ((len - 1) * 8)) & 0xff;
if (nm == cs2) {
if (len != cs2width) {
errno = EILSEQ;
diff --git a/lib/libc/tests/locale/wctomb_test.c b/lib/libc/tests/locale/wctomb_test.c
--- a/lib/libc/tests/locale/wctomb_test.c
+++ b/lib/libc/tests/locale/wctomb_test.c
@@ -41,6 +41,18 @@
#include <atf-c.h>
+ATF_TC_WITHOUT_HEAD(euccs1_test);
+ATF_TC_BODY(euccs1_test, tc)
+{
+ wchar_t wc = 0x8e000000;
+ char buf[MB_LEN_MAX];
+
+ ATF_REQUIRE(strcmp(setlocale(LC_CTYPE, "zh_CN.eucCN"),
+ "zh_CN.eucCN") == 0);
+
+ ATF_REQUIRE(wctomb(&buf[0], wc) == 4);
+}
+
ATF_TC_WITHOUT_HEAD(wctomb_test);
ATF_TC_BODY(wctomb_test, tc)
{
@@ -104,6 +116,7 @@
ATF_TP_ADD_TCS(tp)
{
+ ATF_TP_ADD_TC(tp, euccs1_test);
ATF_TP_ADD_TC(tp, wctomb_test);
return (atf_no_error());
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 12, 6:19 AM (3 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41672413
Default Alt Text
D43262.1794464369.diff (1 KB)
Attached To
Mode
D43262: libc: locale: fix EUC shift check
Attached
Detach File
Event Timeline