VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
author: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> 2009-08-01 21:30:31 +0900 committer: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> 2009-08-01 21:35:21 +0900 commit: 67638e4043083cdc6f10386a75fef87ba46eecb3 parent: ed680c4ad478d0fee9740f7d029087f181346564
Commit Summary:
fat/nls: Fix handling of utf8 invalid char
Diffstat:
1 file changed, 3 insertions, 4 deletions
diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
index 477d37d83b31..b25c218671b3 100644
--- a/fs/nls/nls_base.c
+++ b/fs/nls/nls_base.c
@@ -124,10 +124,10 @@ int utf8s_to_utf16s(const u8 *s, int len, wchar_t *pwcs)
 	while (*s && len > 0) {
 		if (*s & 0x80) {
 			size = utf8_to_utf32(s, len, &u);
-			if (size < 0) {
-				/* Ignore character and move on */
-				size = 1;
-			} else if (u >= PLANE_SIZE) {
+			if (size < 0)
+				return -EINVAL;
+
+			if (u >= PLANE_SIZE) {
 				u -= PLANE_SIZE;
 				*op++ = (wchar_t) (SURROGATE_PAIR |
 						((u >> 10) & SURROGATE_BITS));