]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-114492: Initialize struct termios before calling tcgetattr() (GH-114495...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 23 Jan 2024 21:53:13 +0000 (22:53 +0100)
committerGitHub <noreply@github.com>
Tue, 23 Jan 2024 21:53:13 +0000 (21:53 +0000)
On Alpine Linux it could leave some field non-initialized.
(cherry picked from commit d22c066b802592932f9eb18434782299e80ca42e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst [new file with mode: 0644]
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 (file)
index 0000000..8df8299
--- /dev/null
@@ -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.
index be5d099072c8eebc47d8b0d1a38043f872db4f91..23771b2ce99f828fc6dbc2a9ad743730037295d1 100644 (file)
@@ -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