Преглед на файлове

i18n: Fix mbrtowc function to handle 0xc0 and 0xc1 sequence.

When the first byte of the multibyte sequence start with 0xc0
or 0xc1, the whole sequence is invalid, so the return value must
be -1 (instead of -2).
Fix bug #686.

Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Acked-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Carmelo Amoroso преди 17 години
родител
ревизия
cdc25d86e3
променени са 1 файла, в които са добавени 2 реда и са изтрити 1 реда
  1. 2 1
      libc/misc/wchar/wchar.c

+ 2 - 1
libc/misc/wchar/wchar.c

@@ -488,7 +488,8 @@ size_t attribute_hidden _wchar_utf8sntowcs(wchar_t *__restrict pwc, size_t wn,
 #ifdef __UCLIBC_MJN3_ONLY__
 #warning TODO: Fix range for 16 bit wchar_t case.
 #endif
-			if ( ((unsigned char)(s[-1] - 0xc0)) < (0xfe - 0xc0) ) {
+			if (( ((unsigned char)(s[-1] - 0xc0)) < (0xfe - 0xc0) ) &&
+			(((unsigned char)s[-1] != 0xc0 ) && ((unsigned char)s[-1] != 0xc1 ))) {
 				goto START;
 			}
 		BAD: