Skip to content

Commit 386c72d

Browse files
[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 d22c066) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent f63dec9 commit 386c72d

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Make the result of :func:`termios.tcgetattr` reproducible on Alpine Linux.
2+
Previously it could leave a random garbage in some fields.

Modules/termios.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ termios_tcgetattr_impl(PyObject *module, int fd)
8484
struct termios mode;
8585
int r;
8686

87+
/* Alpine Linux can leave some fields uninitialized. */
88+
memset(&mode, 0, sizeof(mode));
8789
Py_BEGIN_ALLOW_THREADS
8890
r = tcgetattr(fd, &mode);
8991
Py_END_ALLOW_THREADS

0 commit comments

Comments
 (0)