From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 23 Jan 2024 21:53:13 +0000 (+0100) Subject: [3.11] gh-114492: Initialize struct termios before calling tcgetattr() (GH-114495... X-Git-Tag: v3.11.8~91 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=666d07f241970482f17dc4bf7a5dff737d9b8357;p=thirdparty%2FPython%2Fcpython.git [3.11] gh-114492: Initialize struct termios before calling tcgetattr() (GH-114495) (GH-114503) On Alpine Linux it could leave some field non-initialized. (cherry picked from commit d22c066b802592932f9eb18434782299e80ca42e) Co-authored-by: Serhiy Storchaka --- 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 000000000000..8df8299d0dff --- /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 be5d099072c8..23771b2ce99f 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