https://github.com/python/cpython/commit/386c72d9928c51aa2c855ce592bd8022da3b407f
commit: 386c72d9928c51aa2c855ce592bd8022da3b407f
branch: 3.12
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: serhiy-storchaka <storch...@gmail.com>
date: 2024-01-23T22:02:02Z
summary:

[3.12] gh-114492: Initialize struct termios before calling tcgetattr() 
(GH-114495) (GH-114502)

On Alpine Linux it could leave some field non-initialized.
(cherry picked from commit d22c066b802592932f9eb18434782299e80ca42e)

Co-authored-by: Serhiy Storchaka <storch...@gmail.com>

files:
A Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst
M Modules/termios.c

diff --git 
a/Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst 
b/Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst
new file mode 100644
index 00000000000000..8df8299d0dffcd
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst
@@ -0,0 +1,2 @@
+Make the result of :func:`termios.tcgetattr` reproducible on Alpine Linux.
+Previously it could leave a random garbage in some fields.
diff --git a/Modules/termios.c b/Modules/termios.c
index c3d96cc5b2c00d..402e6ac908a176 100644
--- a/Modules/termios.c
+++ b/Modules/termios.c
@@ -84,6 +84,8 @@ termios_tcgetattr_impl(PyObject *module, int fd)
     struct termios mode;
     int r;
 
+    /* Alpine Linux can leave some fields uninitialized. */
+    memset(&mode, 0, sizeof(mode));
     Py_BEGIN_ALLOW_THREADS
     r = tcgetattr(fd, &mode);
     Py_END_ALLOW_THREADS

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to