Skip to content

Commit 0ee9619

Browse files
gh-97728: Argument Clinic: Fix uninitialized variable in the Py_UNICODE converter (GH-97729)
It affects function os.system() on Windows and Windows-specific modules winreg, _winapi, _overlapped, and _msi.
1 parent e738b51 commit 0ee9619

File tree

8 files changed

+46
-42
lines changed

8 files changed

+46
-42
lines changed

Lib/test/clinic.test

+6-6
Original file line numberDiff line numberDiff line change
@@ -1803,12 +1803,12 @@ static PyObject *
18031803
test_Py_UNICODE_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
18041804
{
18051805
PyObject *return_value = NULL;
1806-
const Py_UNICODE *a;
1807-
const Py_UNICODE *b;
1808-
const Py_UNICODE *c;
1809-
const Py_UNICODE *d;
1806+
const Py_UNICODE *a = NULL;
1807+
const Py_UNICODE *b = NULL;
1808+
const Py_UNICODE *c = NULL;
1809+
const Py_UNICODE *d = NULL;
18101810
Py_ssize_t d_length;
1811-
const Py_UNICODE *e;
1811+
const Py_UNICODE *e = NULL;
18121812
Py_ssize_t e_length;
18131813

18141814
if (!_PyArg_ParseStack(args, nargs, "O&O&O&u#Z#:test_Py_UNICODE_converter",
@@ -1833,7 +1833,7 @@ test_Py_UNICODE_converter_impl(PyObject *module, const Py_UNICODE *a,
18331833
const Py_UNICODE *b, const Py_UNICODE *c,
18341834
const Py_UNICODE *d, Py_ssize_t d_length,
18351835
const Py_UNICODE *e, Py_ssize_t e_length)
1836-
/*[clinic end generated code: output=4d426808cdbb3ea3 input=064a3b68ad7f04b0]*/
1836+
/*[clinic end generated code: output=9f34a249b3071fdd input=064a3b68ad7f04b0]*/
18371837

18381838

18391839
/*[clinic input]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix possible crashes caused by the use of uninitialized variables when pass
2+
invalid arguments in :func:`os.system` on Windows and in Windows-specific
3+
modules (like ``winreg``).

Modules/clinic/_winapi.c.h

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/overlapped.c.h

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/posixmodule.c.h

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PC/clinic/_msi.c.h

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PC/clinic/winreg.c.h

+17-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tools/clinic/clinic.py

+1
Original file line numberDiff line numberDiff line change
@@ -3586,6 +3586,7 @@ def converter_init(self, *, accept={str}, zeroes=False):
35863586
self.converter = '_PyUnicode_WideCharString_Opt_Converter'
35873587
else:
35883588
fail("Py_UNICODE_converter: illegal 'accept' argument " + repr(accept))
3589+
self.c_default = "NULL"
35893590

35903591
def cleanup(self):
35913592
if not self.length:

0 commit comments

Comments
 (0)