|
@@ -28,6 +28,9 @@
|
|
|
|
|
|
#include "udf_sb.h"
|
|
#include "udf_sb.h"
|
|
|
|
|
|
|
|
+#define SURROGATE_MASK 0xfffff800
|
|
|
|
+#define SURROGATE_PAIR 0x0000d800
|
|
|
|
+
|
|
static int udf_uni2char_utf8(wchar_t uni,
|
|
static int udf_uni2char_utf8(wchar_t uni,
|
|
unsigned char *out,
|
|
unsigned char *out,
|
|
int boundlen)
|
|
int boundlen)
|
|
@@ -37,6 +40,9 @@ static int udf_uni2char_utf8(wchar_t uni,
|
|
if (boundlen <= 0)
|
|
if (boundlen <= 0)
|
|
return -ENAMETOOLONG;
|
|
return -ENAMETOOLONG;
|
|
|
|
|
|
|
|
+ if ((uni & SURROGATE_MASK) == SURROGATE_PAIR)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
if (uni < 0x80) {
|
|
if (uni < 0x80) {
|
|
out[u_len++] = (unsigned char)uni;
|
|
out[u_len++] = (unsigned char)uni;
|
|
} else if (uni < 0x800) {
|
|
} else if (uni < 0x800) {
|