Skip to content

Commit 55b922d

Browse files
committed
HexEditor plugin creates an empty folder "plugins\Compare" #10
fix additional finding regarding unchecked config path size from NPPM_GETPLUGINSCONFIGDIR, needs to be < MAX_PATH otherwise an error is returned by N++ and the buffer is empty -> just return in this case
1 parent c0ba456 commit 55b922d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

HexEditor/src/Hex.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,18 @@ extern "C" __declspec(dllexport) BOOL isUnicode()
326326
*/
327327
void loadSettings(void)
328328
{
329-
/* initialize the config directory */
330-
::SendMessage(nppData._nppHandle, NPPM_GETPLUGINSCONFIGDIR, MAX_PATH, (LPARAM)configPath);
331-
::PathRemoveBackslash(configPath);
329+
/* get the length of config directory path */
330+
INT dirPathLength = (INT)::SendMessage(nppData._nppHandle, NPPM_GETPLUGINSCONFIGDIR, 0, (LPARAM)NULL);
331+
if(dirPathLength >0 && dirPathLength < MAX_PATH)
332+
{
333+
::SendMessage(nppData._nppHandle, NPPM_GETPLUGINSCONFIGDIR, MAX_PATH, (LPARAM)configPath);
334+
::PathRemoveBackslash(configPath);
335+
}
336+
else
337+
{
338+
//no path to config dir or path is too long for allocated array with size MAX_PATH
339+
return;
340+
}
332341

333342
/* Test if config path exist, if not create */
334343
if (::PathFileExists(configPath) == FALSE)

0 commit comments

Comments
 (0)