https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f9b2b1a6cd106ab46d7fa…
commit f9b2b1a6cd106ab46d7fa49369cc46ca933158cd
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Oct 20 12:29:29 2022 +0900
Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
CommitDate: Thu Oct 20 12:29:29 2022 +0900
[IMM32] Use UNICODE_NULL for null characters
CORE-11700
---
dll/win32/imm32/ime.c | 8 ++++----
dll/win32/imm32/utils.c | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dll/win32/imm32/ime.c b/dll/win32/imm32/ime.c
index de34b8d90ce..403d831a9b6 100644
--- a/dll/win32/imm32/ime.c
+++ b/dll/win32/imm32/ime.c
@@ -69,7 +69,7 @@ BOOL APIENTRY Imm32InquireIme(PIMEDPI pImeDpi)
return FALSE;
}
- szUIClass[_countof(szUIClass) - 1] = 0;
+ szUIClass[_countof(szUIClass) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
if (pImeInfo->dwPrivateDataSize == 0)
pImeInfo->dwPrivateDataSize = sizeof(DWORD);
@@ -1224,7 +1224,7 @@ LRESULT WINAPI ImmEscapeA(HKL hKL, HIMC hIMC, UINT uSubFunc, LPVOID
lpData)
ret = ImeDpi_Escape(pImeDpi, hIMC, uSubFunc, szW, hKL);
if (ret)
{
- szW[_countof(szW) - 1] = 0;
+ szW[_countof(szW) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
WideCharToMultiByte(pImeDpi->uCodePage, 0, szW, -1,
lpData, MAX_IMM_FILENAME, NULL, NULL);
((LPSTR)lpData)[MAX_IMM_FILENAME - 1] = 0;
@@ -1235,7 +1235,7 @@ LRESULT WINAPI ImmEscapeA(HKL hKL, HIMC hIMC, UINT uSubFunc, LPVOID
lpData)
case IME_ESC_HANJA_MODE:
MultiByteToWideChar(pImeDpi->uCodePage, MB_PRECOMPOSED,
lpData, -1, szW, _countof(szW));
- szW[_countof(szW) - 1] = 0;
+ szW[_countof(szW) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
ret = ImeDpi_Escape(pImeDpi, hIMC, uSubFunc, szW, hKL);
break;
@@ -1304,7 +1304,7 @@ LRESULT WINAPI ImmEscapeW(HKL hKL, HIMC hIMC, UINT uSubFunc, LPVOID
lpData)
szA[_countof(szA) - 1] = 0;
MultiByteToWideChar(pImeDpi->uCodePage, MB_PRECOMPOSED,
szA, -1, lpData, MAX_IMM_FILENAME);
- ((LPWSTR)lpData)[MAX_IMM_FILENAME - 1] = 0;
+ ((LPWSTR)lpData)[MAX_IMM_FILENAME - 1] = UNICODE_NULL; /* Avoid buffer
overrun */
}
break;
diff --git a/dll/win32/imm32/utils.c b/dll/win32/imm32/utils.c
index cde837ece0e..3616f7ea39c 100644
--- a/dll/win32/imm32/utils.c
+++ b/dll/win32/imm32/utils.c
@@ -904,7 +904,7 @@ UINT APIENTRY Imm32GetImeLayout(PREG_IME pLayouts, UINT cLayouts)
szImeFileName[0] = 0;
cbData = sizeof(szImeFileName);
RegQueryValueExW(hkeyIME, L"Ime File", NULL, NULL,
(LPBYTE)szImeFileName, &cbData);
- szImeFileName[_countof(szImeFileName) - 1] = 0;
+ szImeFileName[_countof(szImeFileName) - 1] = UNICODE_NULL; /* Avoid buffer
overrun */
RegCloseKey(hkeyIME);
@@ -997,7 +997,7 @@ BOOL APIENTRY Imm32WriteImeLayout(HKL hKL, LPCWSTR pchFilePart,
LPCWSTR pszLayou
cbData = sizeof(szPreloadKey);
lError = RegQueryValueExW(hkeyPreload, szPreloadNumber, NULL, NULL,
(LPBYTE)szPreloadKey, &cbData);
- szPreloadKey[_countof(szPreloadKey) - 1] = 0;
+ szPreloadKey[_countof(szPreloadKey) - 1] = UNICODE_NULL; /* Avoid buffer overrun
*/
if (lError != ERROR_SUCCESS || lstrcmpiW(szImeKey, szPreloadKey) == 0)
break; /* Found an empty room or the same key */