https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7c14c0ed7346c81311d81…
commit 7c14c0ed7346c81311d8179562d489439273dca1
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Mon Mar 20 16:33:11 2023 +0900
Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
CommitDate: Mon Mar 20 16:33:11 2023 +0900
[USER32_APITEST] Follow-up of c39bf0d
Avoid buffer overflow. CORE-15289, CORE-11700
---
modules/rostests/apitests/user32/MessageStateAnalyzer.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/modules/rostests/apitests/user32/MessageStateAnalyzer.c
b/modules/rostests/apitests/user32/MessageStateAnalyzer.c
index 99041bb4ba1..0343ae8ced2 100644
--- a/modules/rostests/apitests/user32/MessageStateAnalyzer.c
+++ b/modules/rostests/apitests/user32/MessageStateAnalyzer.c
@@ -182,7 +182,8 @@ EditWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
MD_msgdump(hwnd, uMsg, wParam, lParam);
/* Add message */
- s_Msgs[s_cMsgs++] = msg;
+ if (s_cMsgs < MAX_MSGS)
+ s_Msgs[s_cMsgs++] = msg;
/* Do inner task */
ret = CallWindowProc(s_fnOldEditWndProc, hwnd, uMsg, wParam, lParam);
@@ -207,7 +208,8 @@ ImeWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
MD_msgdump(hwnd, uMsg, wParam, lParam);
/* Add message */
- s_Msgs[s_cMsgs++] = msg;
+ if (s_cMsgs < MAX_MSGS)
+ s_Msgs[s_cMsgs++] = msg;
/* Do inner task */
ret = CallWindowProc(s_fnOldImeWndProc, hwnd, uMsg, wParam, lParam);
@@ -287,7 +289,8 @@ WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
MD_msgdump(hwnd, uMsg, wParam, lParam);
/* Add message */
- s_Msgs[s_cMsgs++] = msg;
+ if (s_cMsgs < MAX_MSGS)
+ s_Msgs[s_cMsgs++] = msg;
/* Do inner task */
ret = InnerWindowProc(hwnd, uMsg, wParam, lParam);