Replace magic numbers with named constants

Co-authored-by: emako <24737061+emako@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-10-29 14:04:15 +00:00
parent eda48188ca
commit d1f87eebc7
4 changed files with 5 additions and 2 deletions

View File

@@ -26,6 +26,7 @@
#define DOPUS_CLASS L"DOpus.ParentWindow"
#define DOPUS_NAME L"Directory Opus"
#define MSGWINDOW_CLASS L"QuickLook.Native.DOpus.MsgWindow"
#define MAX_BUFFER_SIZE (10 * 1024 * 1024) // 10MB limit for IPC data
HWND hMsgWnd;
HANDLE hGetResultEvent;
@@ -137,7 +138,7 @@ LRESULT CALLBACK DOpus::msgWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
{
auto cds = reinterpret_cast<PCOPYDATASTRUCT>(lParam);
// Validate COPYDATASTRUCT and enforce reasonable size limit (10MB)
if (cds == nullptr || cds->lpData == nullptr || cds->cbData == 0 || cds->cbData > 10 * 1024 * 1024)
if (cds == nullptr || cds->lpData == nullptr || cds->cbData == 0 || cds->cbData > MAX_BUFFER_SIZE)
{
return 0;
}

View File

@@ -92,7 +92,7 @@ LRESULT CALLBACK MultiCommander::msgWindowProc(HWND hWnd, UINT uMsg, WPARAM wPar
auto cds = reinterpret_cast<PCOPYDATASTRUCT>(lParam);
// Validate COPYDATASTRUCT and enforce reasonable size limit (10MB)
if (cds == nullptr || cds->lpData == nullptr || cds->cbData == 0 || cds->cbData > 10 * 1024 * 1024)
if (cds == nullptr || cds->lpData == nullptr || cds->cbData == 0 || cds->cbData > MAX_BUFFER_SIZE)
{
SetEvent(hGetResultEvent);
return 0;

View File

@@ -19,6 +19,7 @@
#define MULTICMD_CPF_GETCURITEMFULL 0x00000010L // Get full path of current item (file or folder) in focus
#define MULTICMD_CPF_SOURCE 0x00000400L // Go to the new path in the source panel side
#define MAX_BUFFER_SIZE (10 * 1024 * 1024) // 10MB limit for IPC data
#define MULTICMD_CLASS L"MultiCommander MainWnd"
#define MULTICMD_MSGWINDOW_CLASS L"QuickLook.Native.MultiCmd.MsgWindow"

View File

@@ -0,0 +1 @@
.