Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7b36016a
Commit
7b36016a
authored
Dec 14, 2018
by
Vladimir Matveev
Committed by
Serhiy Storchaka
Dec 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-31446: Copy command line that should be passed to CreateProcessW(). (GH-11141)
parent
08c2ba07
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
8 deletions
+28
-8
Misc/NEWS.d/next/Library/2018-12-12-22-52-34.bpo-31446.l--Fjz.rst
...S.d/next/Library/2018-12-12-22-52-34.bpo-31446.l--Fjz.rst
+2
-0
Modules/_winapi.c
Modules/_winapi.c
+20
-4
Modules/clinic/_winapi.c.h
Modules/clinic/_winapi.c.h
+6
-4
No files found.
Misc/NEWS.d/next/Library/2018-12-12-22-52-34.bpo-31446.l--Fjz.rst
0 → 100644
View file @
7b36016a
Copy command line that was passed to CreateProcessW since this function can
change the content of the input buffer.
Modules/_winapi.c
View file @
7b36016a
...
@@ -975,7 +975,8 @@ cleanup:
...
@@ -975,7 +975,8 @@ cleanup:
_winapi.CreateProcess
_winapi.CreateProcess
application_name: Py_UNICODE(accept={str, NoneType})
application_name: Py_UNICODE(accept={str, NoneType})
command_line: Py_UNICODE(accept={str, NoneType})
command_line: object
Can be str or None
proc_attrs: object
proc_attrs: object
Ignored internally, can be None.
Ignored internally, can be None.
thread_attrs: object
thread_attrs: object
...
@@ -995,12 +996,12 @@ process ID, and thread ID.
...
@@ -995,12 +996,12 @@ process ID, and thread ID.
static
PyObject
*
static
PyObject
*
_winapi_CreateProcess_impl
(
PyObject
*
module
,
Py_UNICODE
*
application_name
,
_winapi_CreateProcess_impl
(
PyObject
*
module
,
Py_UNICODE
*
application_name
,
Py
_UNICODE
*
command_line
,
PyObject
*
proc_attrs
,
Py
Object
*
command_line
,
PyObject
*
proc_attrs
,
PyObject
*
thread_attrs
,
BOOL
inherit_handles
,
PyObject
*
thread_attrs
,
BOOL
inherit_handles
,
DWORD
creation_flags
,
PyObject
*
env_mapping
,
DWORD
creation_flags
,
PyObject
*
env_mapping
,
Py_UNICODE
*
current_directory
,
Py_UNICODE
*
current_directory
,
PyObject
*
startup_info
)
PyObject
*
startup_info
)
/*[clinic end generated code: output=
4652a33aff4b0ae1 input=4a43b05038d639bb
]*/
/*[clinic end generated code: output=
2ecaab46a05e3123 input=42ac293eaea03fc4
]*/
{
{
PyObject
*
ret
=
NULL
;
PyObject
*
ret
=
NULL
;
BOOL
result
;
BOOL
result
;
...
@@ -1008,6 +1009,7 @@ _winapi_CreateProcess_impl(PyObject *module, Py_UNICODE *application_name,
...
@@ -1008,6 +1009,7 @@ _winapi_CreateProcess_impl(PyObject *module, Py_UNICODE *application_name,
STARTUPINFOEXW
si
;
STARTUPINFOEXW
si
;
PyObject
*
environment
=
NULL
;
PyObject
*
environment
=
NULL
;
wchar_t
*
wenvironment
;
wchar_t
*
wenvironment
;
wchar_t
*
command_line_copy
=
NULL
;
AttributeList
attribute_list
=
{
0
};
AttributeList
attribute_list
=
{
0
};
ZeroMemory
(
&
si
,
sizeof
(
si
));
ZeroMemory
(
&
si
,
sizeof
(
si
));
...
@@ -1042,10 +1044,23 @@ _winapi_CreateProcess_impl(PyObject *module, Py_UNICODE *application_name,
...
@@ -1042,10 +1044,23 @@ _winapi_CreateProcess_impl(PyObject *module, Py_UNICODE *application_name,
goto
cleanup
;
goto
cleanup
;
si
.
lpAttributeList
=
attribute_list
.
attribute_list
;
si
.
lpAttributeList
=
attribute_list
.
attribute_list
;
if
(
PyUnicode_Check
(
command_line
))
{
command_line_copy
=
PyUnicode_AsWideCharString
(
command_line
,
NULL
);
if
(
command_line_copy
==
NULL
)
{
goto
cleanup
;
}
}
else
if
(
command_line
!=
Py_None
)
{
PyErr_Format
(
PyExc_TypeError
,
"CreateProcess() argument 2 must be str or None, not %s"
,
Py_TYPE
(
command_line
)
->
tp_name
);
goto
cleanup
;
}
Py_BEGIN_ALLOW_THREADS
Py_BEGIN_ALLOW_THREADS
result
=
CreateProcessW
(
application_name
,
result
=
CreateProcessW
(
application_name
,
command_line
,
command_line
_copy
,
NULL
,
NULL
,
NULL
,
NULL
,
inherit_handles
,
inherit_handles
,
...
@@ -1069,6 +1084,7 @@ _winapi_CreateProcess_impl(PyObject *module, Py_UNICODE *application_name,
...
@@ -1069,6 +1084,7 @@ _winapi_CreateProcess_impl(PyObject *module, Py_UNICODE *application_name,
pi
.
dwThreadId
);
pi
.
dwThreadId
);
cleanup:
cleanup:
PyMem_Free
(
command_line_copy
);
Py_XDECREF
(
environment
);
Py_XDECREF
(
environment
);
freeattributelist
(
&
attribute_list
);
freeattributelist
(
&
attribute_list
);
...
...
Modules/clinic/_winapi.c.h
View file @
7b36016a
...
@@ -286,6 +286,8 @@ PyDoc_STRVAR(_winapi_CreateProcess__doc__,
...
@@ -286,6 +286,8 @@ PyDoc_STRVAR(_winapi_CreateProcess__doc__,
"
\n
"
"
\n
"
"Create a new process and its primary thread.
\n
"
"Create a new process and its primary thread.
\n
"
"
\n
"
"
\n
"
" command_line
\n
"
" Can be str or None
\n
"
" proc_attrs
\n
"
" proc_attrs
\n
"
" Ignored internally, can be None.
\n
"
" Ignored internally, can be None.
\n
"
" thread_attrs
\n
"
" thread_attrs
\n
"
...
@@ -299,7 +301,7 @@ PyDoc_STRVAR(_winapi_CreateProcess__doc__,
...
@@ -299,7 +301,7 @@ PyDoc_STRVAR(_winapi_CreateProcess__doc__,
static
PyObject
*
static
PyObject
*
_winapi_CreateProcess_impl
(
PyObject
*
module
,
Py_UNICODE
*
application_name
,
_winapi_CreateProcess_impl
(
PyObject
*
module
,
Py_UNICODE
*
application_name
,
Py
_UNICODE
*
command_line
,
PyObject
*
proc_attrs
,
Py
Object
*
command_line
,
PyObject
*
proc_attrs
,
PyObject
*
thread_attrs
,
BOOL
inherit_handles
,
PyObject
*
thread_attrs
,
BOOL
inherit_handles
,
DWORD
creation_flags
,
PyObject
*
env_mapping
,
DWORD
creation_flags
,
PyObject
*
env_mapping
,
Py_UNICODE
*
current_directory
,
Py_UNICODE
*
current_directory
,
...
@@ -310,7 +312,7 @@ _winapi_CreateProcess(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
...
@@ -310,7 +312,7 @@ _winapi_CreateProcess(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
{
PyObject
*
return_value
=
NULL
;
PyObject
*
return_value
=
NULL
;
Py_UNICODE
*
application_name
;
Py_UNICODE
*
application_name
;
Py
_UNICODE
*
command_line
;
Py
Object
*
command_line
;
PyObject
*
proc_attrs
;
PyObject
*
proc_attrs
;
PyObject
*
thread_attrs
;
PyObject
*
thread_attrs
;
BOOL
inherit_handles
;
BOOL
inherit_handles
;
...
@@ -319,7 +321,7 @@ _winapi_CreateProcess(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
...
@@ -319,7 +321,7 @@ _winapi_CreateProcess(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
Py_UNICODE
*
current_directory
;
Py_UNICODE
*
current_directory
;
PyObject
*
startup_info
;
PyObject
*
startup_info
;
if
(
!
_PyArg_ParseStack
(
args
,
nargs
,
"Z
Z
OOikOZO:CreateProcess"
,
if
(
!
_PyArg_ParseStack
(
args
,
nargs
,
"Z
O
OOikOZO:CreateProcess"
,
&
application_name
,
&
command_line
,
&
proc_attrs
,
&
thread_attrs
,
&
inherit_handles
,
&
creation_flags
,
&
env_mapping
,
&
current_directory
,
&
startup_info
))
{
&
application_name
,
&
command_line
,
&
proc_attrs
,
&
thread_attrs
,
&
inherit_handles
,
&
creation_flags
,
&
env_mapping
,
&
current_directory
,
&
startup_info
))
{
goto
exit
;
goto
exit
;
}
}
...
@@ -941,4 +943,4 @@ _winapi_GetFileType(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P
...
@@ -941,4 +943,4 @@ _winapi_GetFileType(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P
exit:
exit:
return
return_value
;
return
return_value
;
}
}
/*[clinic end generated code: output=
915dd640329de0c0
input=a9049054013a1b77]*/
/*[clinic end generated code: output=
1568ad4bd625f2af
input=a9049054013a1b77]*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment