aports/main/python3/114495-fix-termios.patch
2024-01-24 13:28:48 +00:00

36 lines
1.5 KiB
Diff

Patch-Source: https://github.com/python/cpython/pull/114495
From 7f059373349d6e9e6504b2957e09921642aaacde Mon Sep 17 00:00:00 2001
From: Serhiy Storchaka <storchaka@gmail.com>
Date: Tue, 23 Jan 2024 21:20:54 +0200
Subject: [PATCH] gh-114492: Initialize struct termios before calling
tcgetattr()
On Alpine Linux it could leave some field non-initialized.
---
.../next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst | 2 ++
Modules/termios.c | 2 ++
2 files changed, 4 insertions(+)
create mode 100644 Misc/NEWS.d/next/Library/2024-01-23-21-20-40.gh-issue-114492.vKxl5o.rst
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 c4f0fd9d50044a..69dbd88be5fcc2 100644
--- a/Modules/termios.c
+++ b/Modules/termios.c
@@ -98,6 +98,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