Skip to content

Commit

Permalink
Fix file name buffer size for PAL's CreateProcess (#109436)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregg-miskelly authored Nov 6, 2024
1 parent 44115f2 commit 3116db9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/coreclr/pal/src/thread/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3630,10 +3630,16 @@ getFileName(
wcEnd = *lpEnd;
*lpEnd = 0x0000;

/* Convert to ASCII */
/* Convert to UTF-8 */
int size = 0;
int length = (PAL_wcslen(lpCommandLine)+1) * sizeof(WCHAR);
lpFileName = lpFileNamePS.OpenStringBuffer(length);
int length = WideCharToMultiByte(CP_ACP, 0, lpCommandLine, -1, NULL, 0, NULL, NULL);
if (length == 0)
{
ERROR("Failed to calculate the required buffer length.\n");
return FALSE;
};

lpFileName = lpFileNamePS.OpenStringBuffer(length - 1);
if (NULL == lpFileName)
{
ERROR("Not Enough Memory!\n");
Expand Down

0 comments on commit 3116db9

Please sign in to comment.