summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/argv/ntapi_tt_array_utf8.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/argv/ntapi_tt_array_utf8.c b/src/argv/ntapi_tt_array_utf8.c
index ed8dd9a..e19ad43 100644
--- a/src/argv/ntapi_tt_array_utf8.c
+++ b/src/argv/ntapi_tt_array_utf8.c
@@ -307,7 +307,7 @@ int32_t __stdcall __ntapi_tt_array_convert_utf8_to_utf16(
ubound--;
ubound--;
- for (; arrv && *arrv; arrv++,warrv++) {
+ for (; arrv && *arrv && (wch<ubound); arrv++,warrv++) {
*warrv = wch - wdiff;
ch = *arrv + diff;
@@ -385,6 +385,9 @@ int32_t __stdcall __ntapi_tt_array_convert_utf8_to_utf16(
*wch++ = 0;
}
+ if (wch == ubound)
+ return NT_STATUS_BUFFER_TOO_SMALL;
+
*wch++ = 0;
*warrv = 0;
*bytes_written = sizeof(wchar16_t) * (wch - buffer);