8000 gh-114492: Initialize struct termios before calling tcgetattr() (GH-1… · python/cpython@d22c066 · GitHub
[go: up one dir, main page]

Skip to content

Commit d22c066

Browse files
gh-114492: Initialize struct termios before calling tcgetattr() (GH-114495)
On Alpine Linux it could leave some field non-initialized.
1 parent ce01ab5 commit d22c066

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
@@ -98,6 +98,8 @@ termios_tcgetattr_impl(PyObject *module, int fd)
9898
struct termios mode;
9999
int r;
100100

101+
/* Alpine Linux can leave some fields uninitialized. */
102+
memset(&mode, 0, sizeof(mode));
101103
Py_BEGIN_ALLOW_THREADS
102104
r = tcgetattr(fd, &mode);
103105
Py_END_ALLOW_THREADS

0 commit comments

Comments
 (0)
0