Skip to content

Commit

Permalink
[3.11] gh-97728: Argument Clinic: Fix uninitialized variable in the P…
Browse files Browse the repository at this point in the history
…y_UNICODE converter (GH-97729) (GH-97757)

It affects function os.system() on Windows and Windows-specific modules
winreg, _winapi, _overlapped, and _msi.
(cherry picked from commit 0ee9619)
  • Loading branch information
serhiy-storchaka committed Oct 3, 2022
1 parent 3db0368 commit f07ee41
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 40 deletions.
12 changes: 6 additions & 6 deletions Lib/test/clinic.test
Original file line number Diff line number Diff line change
Expand Up @@ -1803,12 +1803,12 @@ static PyObject *
test_Py_UNICODE_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
const Py_UNICODE *a;
const Py_UNICODE *b;
const Py_UNICODE *c;
const Py_UNICODE *d;
const Py_UNICODE *a = NULL;
const Py_UNICODE *b = NULL;
const Py_UNICODE *c = NULL;
const Py_UNICODE *d = NULL;
Py_ssize_t d_length;
const Py_UNICODE *e;
const Py_UNICODE *e = NULL;
Py_ssize_t e_length;

if (!_PyArg_ParseStack(args, nargs, "O&O&O&u#Z#:test_Py_UNICODE_converter",
Expand Down Expand Up @@ -1839,7 +1839,7 @@ test_Py_UNICODE_converter_impl(PyObject *module, const Py_UNICODE *a,
const Py_UNICODE *b, const Py_UNICODE *c,
const Py_UNICODE *d, Py_ssize_t d_length,
const Py_UNICODE *e, Py_ssize_t e_length)
/*[clinic end generated code: output=45e92604de227552 input=064a3b68ad7f04b0]*/
/*[clinic end generated code: output=9d41b3a38a0f6f2f input=064a3b68ad7f04b0]*/


/*[clinic input]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix possible crashes caused by the use of uninitialized variables when pass
invalid arguments in :func:`os.system` on Windows and in Windows-specific
modules (like ``winreg``).
14 changes: 7 additions & 7 deletions Modules/clinic/_winapi.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Modules/clinic/overlapped.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Modules/clinic/posixmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions PC/clinic/_msi.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions PC/clinic/winreg.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3522,6 +3522,7 @@ def converter_init(self, *, accept={str}, zeroes=False):
self.converter = '_PyUnicode_WideCharString_Opt_Converter'
else:
fail("Py_UNICODE_converter: illegal 'accept' argument " + repr(accept))
self.c_default = "NULL"

def cleanup(self):
if not self.length:
Expand Down

0 comments on commit f07ee41

Please sign in to comment.