diff options
Diffstat (limited to 'fs/udf/unicode.c')
-rw-r--r-- | fs/udf/unicode.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c index f897e55f2cd0..16a8ad21b77e 100644 --- a/fs/udf/unicode.c +++ b/fs/udf/unicode.c | |||
@@ -28,6 +28,9 @@ | |||
28 | 28 | ||
29 | #include "udf_sb.h" | 29 | #include "udf_sb.h" |
30 | 30 | ||
31 | #define SURROGATE_MASK 0xfffff800 | ||
32 | #define SURROGATE_PAIR 0x0000d800 | ||
33 | |||
31 | static int udf_uni2char_utf8(wchar_t uni, | 34 | static int udf_uni2char_utf8(wchar_t uni, |
32 | unsigned char *out, | 35 | unsigned char *out, |
33 | int boundlen) | 36 | int boundlen) |
@@ -37,6 +40,9 @@ static int udf_uni2char_utf8(wchar_t uni, | |||
37 | if (boundlen <= 0) | 40 | if (boundlen <= 0) |
38 | return -ENAMETOOLONG; | 41 | return -ENAMETOOLONG; |
39 | 42 | ||
43 | if ((uni & SURROGATE_MASK) == SURROGATE_PAIR) | ||
44 | return -EINVAL; | ||
45 | |||
40 | if (uni < 0x80) { | 46 | if (uni < 0x80) { |
41 | out[u_len++] = (unsigned char)uni; | 47 | out[u_len++] = (unsigned char)uni; |
42 | } else if (uni < 0x800) { | 48 | } else if (uni < 0x800) { |