Skip to content

Commit 769b9dc

Browse files
[3.10] gh-97728: Argument Clinic: Fix uninitialized variable in the Py_UNICODE converter (GH-97729) (GH-97760)
It affects function os.system() on Windows and Windows-specific modules winreg, _winapi, _overlapped, and _msi. (cherry picked from commit 0ee9619)
1 parent e1cbb6f commit 769b9dc

File tree

8 files changed

+44
-40
lines changed

8 files changed

+44
-40
lines changed

Lib/test/clinic.test

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,12 +1805,12 @@ static PyObject *
18051805
test_Py_UNICODE_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
18061806
{
18071807
PyObject *return_value = NULL;
1808-
const Py_UNICODE *a;
1809-
const Py_UNICODE *b;
1810-
const Py_UNICODE *c;
1811-
const Py_UNICODE *d;
1808+
const Py_UNICODE *a = NULL;
1809+
const Py_UNICODE *b = NULL;
1810+
const Py_UNICODE *c = NULL;
1811+
const Py_UNICODE *d = NULL;
18121812
Py_ssize_clean_t d_length;
1813-
const Py_UNICODE *e;
1813+
const Py_UNICODE *e = NULL;
18141814
Py_ssize_clean_t e_length;
18151815

18161816
if (!_PyArg_ParseStack(args, nargs, "O&O&O&u#Z#:test_Py_UNICODE_converter",
@@ -1843,7 +1843,7 @@ test_Py_UNICODE_converter_impl(PyObject *module, const Py_UNICODE *a,
18431843
Py_ssize_clean_t d_length,
18441844
const Py_UNICODE *e,
18451845
Py_ssize_clean_t e_length)
1846-
/*[clinic end generated code: output=ef45e982fedf0b3d input=064a3b68ad7f04b0]*/
1846+
/*[clinic end generated code: output=e45007c49e77ad4a input=064a3b68ad7f04b0]*/
18471847

18481848

18491849
/*[clinic input]
Lines changed: 3 additions & 0 deletions
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

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/overlapped.c.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/posixmodule.c.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PC/clinic/_msi.c.h

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PC/clinic/winreg.c.h

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tools/clinic/clinic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3449,6 +3449,7 @@ def converter_init(self, *, accept={str}, zeroes=False):
34493449
self.converter = '_PyUnicode_WideCharString_Opt_Converter'
34503450
else:
34513451
fail("Py_UNICODE_converter: illegal 'accept' argument " + repr(accept))
3452+
self.c_default = "NULL"
34523453

34533454
def cleanup(self):
34543455
if not self.length:

0 commit comments

Comments
 (0)