summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-08-29 02:57:11 +0000
committermidipix <writeonce@midipix.org>2019-08-29 02:57:11 +0000
commit8344385d981142f4e9ac8328befffb275d3ab411 (patch)
tree94fe7070f282e04720e6eb39d725d90c10a09a0a /src
parent8026377c94712d01108425a5264e91f9db5b1674 (diff)
downloadntapi-8344385d981142f4e9ac8328befffb275d3ab411.tar.bz2
ntapi-8344385d981142f4e9ac8328befffb275d3ab411.tar.xz
__ntapi_tt_array_convert_utf16_to_utf8(): remove input validation requirement.
Diffstat (limited to 'src')
-rw-r--r--src/argv/ntapi_tt_array_utf16.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/argv/ntapi_tt_array_utf16.c b/src/argv/ntapi_tt_array_utf16.c
index 3d58b73..540a7c1 100644
--- a/src/argv/ntapi_tt_array_utf16.c
+++ b/src/argv/ntapi_tt_array_utf16.c
@@ -179,7 +179,6 @@ int32_t __stdcall __ntapi_tt_array_convert_utf16_to_utf8(
*arrv = (char *)(ch-(uintptr_t)base);
wch = *warrv + diff;
- /* all utf-16 streams at stake have been validated */
while (*wch && (ch < ubound)) {
if (*wch <= 0x7F) {
/* from: 00000000 0xxxxxxx (little endian) */
@@ -225,6 +224,12 @@ int32_t __stdcall __ntapi_tt_array_convert_utf16_to_utf8(
/* write the x part */
*ch = (char)(0x80 | wx);
+ } else if (wch[0] >= 0xDC00) {
+ return NT_STATUS_ILLEGAL_CHARACTER;
+ } else if (wch[1] < 0xDC00) {
+ return NT_STATUS_ILLEGAL_CHARACTER;
+ } else if (wch[1] >= 0xE000) {
+ return NT_STATUS_ILLEGAL_CHARACTER;
} else {
/* from: 110110ww wwzzzzyy 110111yy yyxxxxxx (little endian) */
/* to: 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx (utf-8) */