Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:19
erlang
1391-Requote-for-plain-spawn.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1391-Requote-for-plain-spawn.patch of Package erlang
From f0a273c5a5ebfc97cfe1e88341c803b85d2295e4 Mon Sep 17 00:00:00 2001 From: Raimo Niskanen <raimo@erlang.org> Date: Wed, 16 Mar 2022 15:33:10 +0100 Subject: [PATCH 2/2] Requote for plain spawn --- erts/emulator/sys/win32/sys.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/erts/emulator/sys/win32/sys.c b/erts/emulator/sys/win32/sys.c index 2a41222275..fd3cb34130 100644 --- a/erts/emulator/sys/win32/sys.c +++ b/erts/emulator/sys/win32/sys.c @@ -76,8 +76,8 @@ static BOOL create_child_process(wchar_t *, HANDLE, HANDLE, wchar_t **, int *); static int create_pipe(LPHANDLE, LPHANDLE, BOOL, BOOL); static int application_type(const wchar_t* originalName, wchar_t fullPath[MAX_PATH], - BOOL search_in_path, BOOL handle_quotes, - int *error_return); + BOOL search_in_path, BOOL handle_quotes, + int *error_return, BOOL *requote); HANDLE erts_service_event; @@ -1542,6 +1542,7 @@ create_child_process HANDLE hProcess = GetCurrentProcess(); STARTUPINFOW siStartInfo = {0}; wchar_t execPath[MAX_PATH]; + BOOL requote = FALSE; *errno_return = -1; siStartInfo.cb = sizeof(STARTUPINFOW); @@ -1562,7 +1563,8 @@ create_child_process thecommand[cmdlength] = L'\0'; DEBUGF(("spawn command: %S\n", thecommand)); - applType = application_type(thecommand, execPath, TRUE, TRUE, errno_return); + applType = + application_type(thecommand, execPath, TRUE, TRUE, errno_return, &requote); DEBUGF(("application_type returned for (%S) is %d\n", thecommand, applType)); erts_free(ERTS_ALC_T_TMP, (void *) thecommand); if (applType == APPL_NONE) { @@ -1590,10 +1592,16 @@ create_child_process createFlags = 0; } + if (requote) { + wcscat(newcmdline, L"\""); + } wcscat(newcmdline, execPath); + if (requote) { + wcscat(newcmdline, L"\""); + } wcscat(newcmdline, origcmd+cmdlength); DEBUGF(("Creating child process: %S, createFlags = %d\n", newcmdline, createFlags)); - ok = CreateProcessW(execPath, + ok = CreateProcessW((applType == APPL_DOS) ? appname : execPath, newcmdline, NULL, NULL, @@ -1608,7 +1616,8 @@ create_child_process } else { /* ERTS_SPAWN_EXECUTABLE, filename and args are in unicode ({utf16,little}) */ int run_cmd = 0; - applType = application_type(origcmd, execPath, FALSE, FALSE, errno_return); + applType = + application_type(origcmd, execPath, FALSE, FALSE, errno_return, &requote); if (applType == APPL_NONE) { return FALSE; } @@ -1630,7 +1639,8 @@ create_child_process if (run_cmd) { wchar_t cmdPath[MAX_PATH]; int cmdType; - cmdType = application_type(L"cmd.exe", cmdPath, TRUE, FALSE, errno_return); + cmdType = + application_type(L"cmd.exe", cmdPath, TRUE, FALSE, errno_return, &requote); if (cmdType == APPL_NONE || cmdType == APPL_DOS) { return FALSE; } @@ -1822,7 +1832,8 @@ static int application_type (const wchar_t *originalName, /* Name of the applica * application. */ BOOL search_in_path, /* If we should search the system wide path */ BOOL handle_quotes, /* If we should handle quotes around executable */ - int *error_return) /* A place to put an error code */ + int *error_return, /* A place to put an error code */ + BOOL *requote) /* The path needs requoting */ { int applType, i; HANDLE hFile; @@ -1831,18 +1842,17 @@ static int application_type (const wchar_t *originalName, /* Name of the applica DWORD read; IMAGE_DOS_HEADER header; static wchar_t extensions[][5] = {L"", L".com", L".exe", L".bat"}; - int is_quoted; int len; wchar_t xfullpath[MAX_PATH]; len = wcslen(originalName); - is_quoted = handle_quotes && len > 0 && originalName[0] == L'"' && + *requote = handle_quotes && len > 0 && originalName[0] == L'"' && originalName[len-1] == L'"'; applType = APPL_NONE; *error_return = ENOENT; for (i = 0; i < (int) (sizeof(extensions) / sizeof(extensions[0])); i++) { - if(is_quoted) { + if(*requote) { lstrcpynW(xfullpath, originalName+1, MAX_PATH - 7); /* Cannot start using StringCchCopy yet, we support older platforms */ len = wcslen(xfullpath); -- 2.34.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor