From d3fb4862b94f25cd9d6e143133c8f479c3af240f Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Tue, 16 Dec 2025 21:16:42 +0100 Subject: [PATCH] Fix: Stack overflow when operating `CharMsg` --- common/commands.h | 6 ------ server/2015Remote/2015RemoteDlg.cpp | 10 +++++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/common/commands.h b/common/commands.h index 6671580..b74419f 100644 --- a/common/commands.h +++ b/common/commands.h @@ -1147,12 +1147,6 @@ typedef struct CharMsg { memset(data, 0, sizeof(data)); needFree = free; } - char& operator[](int index) { - return data[index]; - } - operator const char* () const { - return data; - } }CharMsg; typedef struct ClientMsg { diff --git a/server/2015Remote/2015RemoteDlg.cpp b/server/2015Remote/2015RemoteDlg.cpp index 3bbb624..a01e500 100644 --- a/server/2015Remote/2015RemoteDlg.cpp +++ b/server/2015Remote/2015RemoteDlg.cpp @@ -2849,14 +2849,14 @@ void CMy2015RemoteDlg::OnOnlineShare() } CharMsg* buf = new CharMsg(dlg.m_str.GetLength()+1); memcpy(buf->data, dlg.m_str, dlg.m_str.GetLength()); - buf[dlg.m_str.GetLength()] = 0; + buf->data[dlg.m_str.GetLength()] = 0; PostMessageA(WM_SHARE_CLIENT, (WPARAM)buf, NULL); } LRESULT CMy2015RemoteDlg::ShareClient(WPARAM wParam, LPARAM lParam) { CharMsg* buf = (CharMsg*)wParam; - int len = strlen(*buf); + int len = strlen(buf->data); BYTE bToken[_MAX_PATH] = { COMMAND_SHARE }; // 目标主机类型 bToken[1] = SHARE_TYPE_YAMA; @@ -3614,15 +3614,15 @@ void CMy2015RemoteDlg::OnOnlineAssignTo() CharMsg* buf2 = new CharMsg(dlg.m_sSecondInput.GetLength() + 1); memcpy(buf1->data, dlg.m_str, dlg.m_str.GetLength()); memcpy(buf2->data, dlg.m_sSecondInput, dlg.m_sSecondInput.GetLength()); - buf1[dlg.m_str.GetLength()] = 0; - buf2[dlg.m_sSecondInput.GetLength()] = 0; + buf1->data[dlg.m_str.GetLength()] = 0; + buf2->data[dlg.m_sSecondInput.GetLength()] = 0; PostMessageA(WM_ASSIGN_CLIENT, (WPARAM)buf1, (LPARAM)buf2); } LRESULT CMy2015RemoteDlg::assignFunction(WPARAM wParam, LPARAM lParam, BOOL all) { CharMsg* buf1 = (CharMsg*)wParam, *buf2 = (CharMsg*)lParam; - int len1 = strlen(*buf1), len2 = strlen(*buf2); + int len1 = strlen(buf1->data), len2 = strlen(buf2->data); BYTE bToken[_MAX_PATH] = { COMMAND_ASSIGN_MASTER }; // 目标主机类型 bToken[1] = SHARE_TYPE_YAMA_FOREVER;